ruff/crates
Alexey Preobrazhenskiy d625f55c05
Nested namespace packages support (#10541)
## 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();
```
2024-03-24 22:53:32 -04:00
..
ruff Accept commas in default copyright pattern (#9498) 2024-03-22 14:42:02 -04:00
ruff_benchmark
ruff_cache
ruff_dev Docs: Link inline settings when not part of options section (#10499) 2024-03-21 16:33:58 +00:00
ruff_diagnostics
ruff_formatter Remove unused dependencies (#10475) 2024-03-19 17:33:47 +01:00
ruff_index
ruff_linter Nested namespace packages support (#10541) 2024-03-24 22:53:32 -04:00
ruff_macros Remove long Iterator::chain sequence in RuleCodePrefix::iter (#10452) 2024-03-18 16:51:20 +01:00
ruff_notebook Remove unused dependencies (#10475) 2024-03-19 17:33:47 +01:00
ruff_python_ast Track ranges of names inside __all__ definitions (#10525) 2024-03-22 18:38:40 +00:00
ruff_python_codegen Track casing of r-string prefixes in the tokenizer and AST (#10314) 2024-03-18 17:18:04 +00:00
ruff_python_formatter Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
ruff_python_index Fix Indexer fails to identify continuation preceded by newline #10351 (#10354) 2024-03-12 00:35:41 -04:00
ruff_python_literal Remove unused dependencies (#10475) 2024-03-19 17:33:47 +01:00
ruff_python_parser chore: remove repetitive words (#10502) 2024-03-21 03:57:16 +00:00
ruff_python_resolver
ruff_python_semantic Correctly handle references in __all__ definitions when renaming symbols in autofixes (#10527) 2024-03-22 20:06:35 +00:00
ruff_python_stdlib [pylint] Include builtin warnings in useless-exception-statement (PLW0133) (#10394) 2024-03-13 15:26:11 -04:00
ruff_python_trivia Remove unused dependencies (#10475) 2024-03-19 17:33:47 +01:00
ruff_server Automatic configuration reloading for ruff server (#10404) 2024-03-21 20:17:07 +00:00
ruff_shrinking Bump version to v0.3.4 (#10515) 2024-03-21 18:08:21 +00:00
ruff_source_file Remove unused dependencies (#10475) 2024-03-19 17:33:47 +01:00
ruff_text_size
ruff_wasm
ruff_workspace Nested namespace packages support (#10541) 2024-03-24 22:53:32 -04:00