-
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 annotated assignments in class and module scopes as runtime (#2667
- Loading branch information
1 parent
286d8c1
commit cb4a221
Showing
7 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_10.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,16 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Tuple, List, Dict | ||
|
||
x: Tuple | ||
|
||
|
||
class C: | ||
x: List | ||
|
||
|
||
def f(): | ||
x: Dict |
14 changes: 14 additions & 0 deletions
14
crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_9.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,14 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Tuple, List, Dict | ||
|
||
x: Tuple | ||
|
||
|
||
class C: | ||
x: List | ||
|
||
|
||
def f(): | ||
x: Dict |
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
6 changes: 6 additions & 0 deletions
6
...les__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_10.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/flake8_type_checking/mod.rs | ||
expression: diagnostics | ||
--- | ||
[] | ||
|
14 changes: 12 additions & 2 deletions
14
...ules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.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,6 +1,16 @@ | ||
--- | ||
source: src/rules/flake8_type_checking/mod.rs | ||
source: crates/ruff/src/rules/flake8_type_checking/mod.rs | ||
expression: diagnostics | ||
--- | ||
[] | ||
- kind: | ||
RuntimeImportInTypeCheckingBlock: | ||
full_name: typing.Any | ||
location: | ||
row: 4 | ||
column: 23 | ||
end_location: | ||
row: 4 | ||
column: 26 | ||
fix: ~ | ||
parent: ~ | ||
|
27 changes: 27 additions & 0 deletions
27
...ules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.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,27 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_type_checking/mod.rs | ||
expression: diagnostics | ||
--- | ||
- kind: | ||
RuntimeImportInTypeCheckingBlock: | ||
full_name: typing.Tuple | ||
location: | ||
row: 4 | ||
column: 23 | ||
end_location: | ||
row: 4 | ||
column: 28 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
RuntimeImportInTypeCheckingBlock: | ||
full_name: typing.List | ||
location: | ||
row: 4 | ||
column: 30 | ||
end_location: | ||
row: 4 | ||
column: 34 | ||
fix: ~ | ||
parent: ~ | ||
|