forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isort): comply with isort when sorting sub-package modules
e.g. packages named "foo.bar" additionally make sure `__future__` imports are always sorted at the very top. Issue astral-sh#3059
- Loading branch information
Showing
8 changed files
with
113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...s/ruff/resources/test/fixtures/isort/separate_subpackage_first_and_third_party_imports.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import sys | ||
import baz | ||
from foo import bar, baz | ||
from foo.bar import blah, blub | ||
from foo.bar.baz import something | ||
import foo | ||
import foo.bar | ||
import foo.bar.baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ts/ruff__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
expression: diagnostics | ||
--- | ||
- kind: | ||
UnsortedImports: ~ | ||
location: | ||
row: 1 | ||
column: 0 | ||
end_location: | ||
row: 9 | ||
column: 0 | ||
fix: | ||
content: "import sys\n\nimport foo\nfrom foo import bar, baz\n\nimport baz\nimport foo.bar\nimport foo.bar.baz\nfrom foo.bar import blah, blub\nfrom foo.bar.baz import something\n" | ||
location: | ||
row: 1 | ||
column: 0 | ||
end_location: | ||
row: 9 | ||
column: 0 | ||
parent: ~ | ||
|
22 changes: 22 additions & 0 deletions
22
...ts/ruff__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
expression: diagnostics | ||
--- | ||
- kind: | ||
UnsortedImports: ~ | ||
location: | ||
row: 1 | ||
column: 0 | ||
end_location: | ||
row: 9 | ||
column: 0 | ||
fix: | ||
content: "import sys\n\nimport baz\nimport foo.bar\nimport foo.bar.baz\nfrom foo.bar import blah, blub\nfrom foo.bar.baz import something\n\nimport foo\nfrom foo import bar, baz\n" | ||
location: | ||
row: 1 | ||
column: 0 | ||
end_location: | ||
row: 9 | ||
column: 0 | ||
parent: ~ | ||
|