-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid removing shadowed imports that point to different symbols (#10387)
This ensures that we don't have incorrect, automated fixes for shadowed names that actually point to different imports. See: #10384.
- Loading branch information
1 parent
2bf1882
commit d59433b
Showing
8 changed files
with
46 additions
and
51 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
crates/ruff_linter/resources/test/fixtures/pyflakes/F811_28.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,6 @@ | ||
"""Regression test for: https://github.com/astral-sh/ruff/issues/10384""" | ||
|
||
import datetime | ||
from datetime import datetime | ||
|
||
datetime(1, 2, 3) |
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
8 changes: 1 addition & 7 deletions
8
...ter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F811_1.py:1:25: F811 [*] Redefinition of unused `FU` from line 1 | ||
F811_1.py:1:25: F811 Redefinition of unused `FU` from line 1 | ||
| | ||
1 | import fu as FU, bar as FU | ||
| ^^ F811 | ||
| | ||
= help: Remove definition: `FU` | ||
|
||
ℹ Safe fix | ||
1 |-import fu as FU, bar as FU | ||
1 |+import fu as FU | ||
|
||
|
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: 1 addition & 7 deletions
8
...ter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F811_2.py:1:34: F811 [*] Redefinition of unused `FU` from line 1 | ||
F811_2.py:1:34: F811 Redefinition of unused `FU` from line 1 | ||
| | ||
1 | from moo import fu as FU, bar as FU | ||
| ^^ F811 | ||
| | ||
= help: Remove definition: `FU` | ||
|
||
ℹ Safe fix | ||
1 |-from moo import fu as FU, bar as FU | ||
1 |+from moo import fu as FU | ||
|
||
|
10 changes: 1 addition & 9 deletions
10
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.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 |
---|---|---|
@@ -1,18 +1,10 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F811_23.py:4:15: F811 [*] Redefinition of unused `foo` from line 3 | ||
F811_23.py:4:15: F811 Redefinition of unused `foo` from line 3 | ||
| | ||
3 | import foo as foo | ||
4 | import bar as foo | ||
| ^^^ F811 | ||
| | ||
= help: Remove definition: `foo` | ||
|
||
ℹ Safe fix | ||
1 1 | """Test that shadowing an explicit re-export produces a warning.""" | ||
2 2 | | ||
3 3 | import foo as foo | ||
4 |-import bar as foo | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.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,12 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F811_28.py:4:22: F811 Redefinition of unused `datetime` from line 3 | ||
| | ||
3 | import datetime | ||
4 | from datetime import datetime | ||
| ^^^^^^^^ F811 | ||
5 | | ||
6 | datetime(1, 2, 3) | ||
| | ||
= help: Remove definition: `datetime` |