mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-03 05:03:33 +00:00
## Summary Our first-party import detection uses a heuristic that doesn't exist in isort: if an import appears to be from within the same package as the containing file, we mark it as first-party. For example, if you have a directory `./foo/__init__.py`, and you import `from foo import bar` in `./foo/baz.py`, we'll mark that as first-party. (See: https://github.com/astral-sh/ruff/pull/1266.) This is often unnecessary, and arguably should be removed (though it does have some important use-cases that are otherwise unserved -- I believe Dagster uses it to ensure that all packages mark imports from within the same package as first-party, but not imports _across_ different first-party packages)... but it does exist, and it does help in cases in which the `src` field is not properly configured. This PR adds an option to turn off this behavior: ```toml [tool.ruff.isort] detect-same-package = false ``` This is being introduced to help codebases migrating over from isort that may want more consistent behavior with their current sorting. ## Test Plan `cargo test` |
||
|---|---|---|
| .. | ||
| flake8_to_ruff | ||
| ruff | ||
| ruff_benchmark | ||
| ruff_cache | ||
| ruff_cli | ||
| ruff_dev | ||
| ruff_diagnostics | ||
| ruff_formatter | ||
| ruff_index | ||
| ruff_macros | ||
| 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_shrinking | ||
| ruff_source_file | ||
| ruff_text_size | ||
| ruff_wasm | ||