-
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 parsing ForwardRef contents as type references
- Loading branch information
1 parent
f58345d
commit 00f5a19
Showing
10 changed files
with
72 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Test case: ForwardRef.""" | ||
|
||
from typing import ForwardRef, TypeVar | ||
|
||
X = ForwardRef("List[int]") | ||
Y: ForwardRef("List[int]") | ||
|
||
Z = TypeVar("X", "List[int]", "int") |
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,7 @@ | ||
"""Test case: f-strings in type annotations.""" | ||
|
||
from typing import List | ||
|
||
x = 1 | ||
|
||
x: List[f"i{x}nt"] = [] |
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,9 @@ | ||
"""Test case: f-strings in future type annotations.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List | ||
|
||
x = 1 | ||
|
||
x: List[f"i{x}nt"] = [] |
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
18 changes: 18 additions & 0 deletions
18
crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_13.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,18 @@ | ||
--- | ||
source: crates/ruff/src/rules/pyflakes/mod.rs | ||
expression: diagnostics | ||
--- | ||
- kind: | ||
name: UndefinedName | ||
body: "Undefined name `List`" | ||
suggestion: ~ | ||
fixable: false | ||
location: | ||
row: 8 | ||
column: 18 | ||
end_location: | ||
row: 8 | ||
column: 22 | ||
fix: ~ | ||
parent: ~ | ||
|
6 changes: 6 additions & 0 deletions
6
crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_14.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,6 @@ | ||
--- | ||
source: crates/ruff/src/rules/pyflakes/mod.rs | ||
expression: diagnostics | ||
--- | ||
[] | ||
|
6 changes: 6 additions & 0 deletions
6
crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_15.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,6 @@ | ||
--- | ||
source: crates/ruff/src/rules/pyflakes/mod.rs | ||
expression: diagnostics | ||
--- | ||
[] | ||
|
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