-
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.
Treat
typing.Annotated
subscripts as type definitions (#10285)
## Summary I think this code has existed since the start of `typing.Annotated` support (#333), and was then overlooked over a series of refactors. Closes #10279.
- Loading branch information
1 parent
7a675cd
commit 57be3fc
Showing
4 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_23.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,7 @@ | ||
"""Test: ensure that we treat strings in `typing.Annotation` as type definitions.""" | ||
|
||
from pathlib import Path | ||
from re import RegexFlag | ||
from typing import Annotated | ||
|
||
p: Annotated["Path", int] = 1 |
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
20 changes: 20 additions & 0 deletions
20
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F401_23.py:4:16: F401 [*] `re.RegexFlag` imported but unused | ||
| | ||
3 | from pathlib import Path | ||
4 | from re import RegexFlag | ||
| ^^^^^^^^^ F401 | ||
5 | from typing import Annotated | ||
| | ||
= help: Remove unused import: `re.RegexFlag` | ||
|
||
ℹ Safe fix | ||
1 1 | """Test: ensure that we treat strings in `typing.Annotation` as type definitions.""" | ||
2 2 | | ||
3 3 | from pathlib import Path | ||
4 |-from re import RegexFlag | ||
5 4 | from typing import Annotated | ||
6 5 | | ||
7 6 | p: Annotated["Path", int] = 1 |