-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEP420 namespaces aren't recognized #740
Comments
This should be fixed in 0.16.2, if you want to check. |
Thanks for looking into it! It still seems to be happening, unfortunately. I threw together a minimal reproduction in a public repo that you can clone and investigate, if you have the appetite for it: https://github.com/charlesnicholson/deptry-pep420-repro Also note the commented-out line in the |
Thanks for taking the time to create a reproduction repository, really appreciate it! I won't be able to take a look right away, but will be during the weekend. In the meantime, I'll re-open the issue as it is not yet fixed. |
Happy to! I set up a manual CI trigger for it, you can see it happening on https://github.com/charlesnicholson/deptry-pep420-repro/actions/runs/9810619739/job/27091137978 |
(closed by mistake by linking a PR to this issue) |
I'm sad that #753 was reverted. Deptry has never been anything close to our slowest performer in our CI suites so we wouldn't have minded if the performance had declined even quite a bit. Plus, all our codebases are small. Would it be possible to make it enabled by configuration, but disabled by default? |
Support for PEP 420 has been added back in 0.19.1 behind Performance should be slightly better as we now do an early return if we find at least one Python file in the directory. There are some possible future improvements listed in #808 to improve performance even more. |
Hmm, I'm still seeing the error in my little repro testbed on v0.19.1: The failed action is here: and the repro, updated to use (Is my example incorrect?) |
Yes sorry, nothing has changed since #740 (comment) for now, we've just reverted the feature because of a performance regression, then put it back behind a feature flag, but as is, meaning it doesn't fully fix your use case. I did not yet take the time to fully dig into it, but still planned at some point. |
We're also hitting this issue where, like @charlesnicholson we use the name of our company as a namespace package to avoid clashes with other third-party packages. Problem The current version (peptry 0.20.0) isn't able to properly recognise these dependencies (or indeed allow us to tell it what the imports are via Indeed, if you have the following in import company.pkg1
import company.pkg2 with the following in dependencies = [
"company-pkg1",
"company-pkg2"
] When running deptry you get: Indeed if you run it with the Dependency 'company-pkg1' with top-levels: {'company'}.
Dependency 'company-pkg2' with top-levels: set(). And there's nothing you can do via config. For example use [tool.deptry.package_module_name_map]
company-pkg1 = "company.pkg1"
company-pkg2 = "company.pkg2" as you now get Solution Ideally you'd add support for importing packages following PEP420 by not assuming that the top-most 'module' (or package), i.e 'company' in this example, is the dependency you're trying to import. Instead it should also check for matches of Alternatively, just allow one to set a Thanks in advance for taking a look at this, and for an otherwise great dependency management tool!! |
In our Python ecosystem, we use PEP420 namespace packages to prefix all of our packages with
companyname
to avoid package name collisions with third-party packages. For example, our directory structures might look like:The pyproject.toml file is pretty vanilla:
When running
deptry .
from the terminal with the current working directory set tosrc/company.foo
, I get this error:This warning makes it seem like
deptry
can't understand these kinds of packages yet, since the package names aren't ambiguous and are, as best I can tell, conforming to https://peps.python.org/pep-0420/#nested-namespace-packages.OS: macOS Sonoma 14.5
Language Version: Python 3.11
Poetry version: we don't use poetry. (We use python and uv, but uv plays no role in our package source layouts).
Thanks for
deptry
! Hopefully it will help us stop shipping broken wheel sets... :-|The text was updated successfully, but these errors were encountered: