-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid infinite loop for required imports with isort: off
- Loading branch information
1 parent
04c9348
commit d423ae4
Showing
11 changed files
with
139 additions
and
45 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
crates/ruff/resources/test/fixtures/isort/required_imports/off.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,4 @@ | ||
# isort: off | ||
|
||
x = 1 | ||
# isort: on |
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
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
19 changes: 19 additions & 0 deletions
19
...ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comment.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,19 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` | ||
| | ||
1 | #!/usr/bin/env python3 | ||
| I002 | ||
2 | | ||
3 | x = 1 | ||
| | ||
= help: Insert required import: `from future import annotations` | ||
|
||
ℹ Suggested fix | ||
1 1 | #!/usr/bin/env python3 | ||
2 |+from __future__ import annotations | ||
2 3 | | ||
3 4 | x = 1 | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
.../snapshots/ruff__rules__isort__tests__required_import_docstring_with_continuation.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,17 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` | ||
| | ||
1 | """Hello, world!"""; x = \ | ||
| I002 | ||
2 | 1; y = 2 | ||
| | ||
= help: Insert required import: `from future import annotations` | ||
|
||
ℹ Suggested fix | ||
1 |-"""Hello, world!"""; x = \ | ||
1 |+"""Hello, world!"""; from __future__ import annotations; x = \ | ||
2 2 | 1; y = 2 | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
...ort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_semicolon.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,15 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` | ||
| | ||
1 | """Hello, world!"""; x = 1 | ||
| I002 | ||
| | ||
= help: Insert required import: `from future import annotations` | ||
|
||
ℹ Suggested fix | ||
1 |-"""Hello, world!"""; x = 1 | ||
1 |+"""Hello, world!"""; from __future__ import annotations; x = 1 | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
.../rules/isort/snapshots/ruff__rules__isort__tests__required_import_existing_import.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,17 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` | ||
| | ||
1 | from __future__ import generator_stop | ||
| I002 | ||
2 | import os | ||
| | ||
= help: Insert required import: `from future import annotations` | ||
|
||
ℹ Suggested fix | ||
1 |+from __future__ import annotations | ||
1 2 | from __future__ import generator_stop | ||
2 3 | import os | ||
|
||
|
20 changes: 20 additions & 0 deletions
20
crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_off.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,20 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` | ||
| | ||
1 | # isort: off | ||
| I002 | ||
2 | | ||
3 | x = 1 | ||
| | ||
= help: Insert required import: `from future import annotations` | ||
|
||
ℹ Suggested fix | ||
1 1 | # isort: off | ||
2 |+from __future__ import annotations | ||
2 3 | | ||
3 4 | x = 1 | ||
4 5 | # isort: on | ||
|
||
|