mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-28 02:39:50 +00:00
## Summary PEP 420 says [nested namespace packages](https://peps.python.org/pep-0420/#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 use `Path::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 to `Path::starts_with`, by caching all directories up to the `namespace_root`: ```ruff let namespace_root = namespace_packages .iter() .filter(|namespace_package| path.starts_with(namespace_package)) .min(); ``` |
||
|---|---|---|
| .. | ||
| ruff | ||
| ruff_benchmark | ||
| ruff_cache | ||
| ruff_dev | ||
| ruff_diagnostics | ||
| ruff_formatter | ||
| ruff_index | ||
| ruff_linter | ||
| ruff_macros | ||
| ruff_notebook | ||
| ruff_python_ast | ||
| ruff_python_codegen | ||
| ruff_python_formatter | ||
| ruff_python_index | ||
| ruff_python_literal | ||
| ruff_python_parser | ||
| ruff_python_resolver | ||
| ruff_python_semantic | ||
| ruff_python_stdlib | ||
| ruff_python_trivia | ||
| ruff_server | ||
| ruff_shrinking | ||
| ruff_source_file | ||
| ruff_text_size | ||
| ruff_wasm | ||
| ruff_workspace | ||