You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When a package with a dashed distribution name (e.g. nats-py) is used in a repository that contains a subpackage with the same name as the import name (e.g. nats), fawltydeps reports the dependency as unused although it is used.
Investigated this further. The problem is how the is_external_import function uses isort.place_module to determine if the module is a third-party module. In turn, the isort function resolves the src dependency here incorrectly and will match the local directory for the dependency instead of correctly identifying it as a external dependency. There is already an issue on the isort repo (FIRSTPARTY/THIRDPARTY detection when --src is specified PyCQA/isort#2429) which mentions a similar issue. Until this is fixed, we either need to have a workaround here (e.g. check the import also via a custom mapping?) or wait for the fix...
Describe the bug
When a package with a dashed distribution name (e.g. nats-py) is used in a repository that contains a subpackage with the same name as the import name (e.g. nats), fawltydeps reports the dependency as unused although it is used.
To Reproduce
Create a repository with the following structure:
Add the following minimal content to pyproject.toml:
Add the following content to the main.py:
Initialize a local .venv & verify that the program is working and it correctly imports the package:
Run fawltydeps on the project
Expected behavior
No undeclared or unused dependencies detected.Observed behavior
Note how the typing-extensions module is not listed
Rename the
natsfolder (e.g. tonuts) & rerun fawltydepsObserved behavior
No undeclared or unused dependencies detected.(as expected)
Environment
Additional context
is_external_importfunction usesisort.place_moduleto determine if the module is a third-party module. In turn, the isort function resolves the src dependency here incorrectly and will match the local directory for the dependency instead of correctly identifying it as a external dependency. There is already an issue on the isort repo (FIRSTPARTY/THIRDPARTY detection when --src is specified PyCQA/isort#2429) which mentions a similar issue. Until this is fixed, we either need to have a workaround here (e.g. check the import also via a custom mapping?) or wait for the fix...