-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Nested namespace packages support #10541
Nested namespace packages support #10541
Conversation
|
Did you run into an issue with this in practice that motivated this change? |
We have a monorepo where all the files are located in an We wanted to use banned-api (TID251), but for python sources it detected |
This test illustrates our situation pretty well. Currently ruff assigns package name |
Okay thanks. I think this is correct. |
Summary
PEP 420 says nested namespace packages are allowed, i.e. marking a directory as a namespace package marks all subdirectories in the subtree as namespace packages.
is_package
is modified to usePath::starts_with
and the order of checks is reversed to do in-memory checks first before hitting the disk.Test Plan
Added unit tests. Previously all tests were run with
namespace_packages == &[]
. Verified that one of the tests was failing before changing the implementation.Future Improvements
The
is_package_with_cache
can probably be rewritten to avoid repeated calls toPath::starts_with
, by caching all directories up to thenamespace_root
: