-
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.
[
flake8-type-checking
] Apply TC008
more eagerly in `TYPE_CHECKING…
…` blocks and disapply it in stubs (#15180) Co-authored-by: Alex Waygood <[email protected]>
- Loading branch information
1 parent
235fdfc
commit 339167d
Showing
8 changed files
with
387 additions
and
20 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...uff_linter/resources/test/fixtures/flake8_type_checking/TC008_typing_execution_context.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,31 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TypeAlias, TYPE_CHECKING | ||
|
||
from foo import Foo | ||
|
||
if TYPE_CHECKING: | ||
from typing import Dict | ||
|
||
OptStr: TypeAlias = str | None | ||
Bar: TypeAlias = Foo[int] | ||
|
||
a: TypeAlias = 'int' # TC008 | ||
b: TypeAlias = 'Dict' # TC008 | ||
c: TypeAlias = 'Foo' # TC008 | ||
d: TypeAlias = 'Foo[str]' # TC008 | ||
e: TypeAlias = 'Foo.bar' # TC008 | ||
f: TypeAlias = 'Foo | None' # TC008 | ||
g: TypeAlias = 'OptStr' # TC008 | ||
h: TypeAlias = 'Bar' # TC008 | ||
i: TypeAlias = Foo['str'] # TC008 | ||
j: TypeAlias = 'Baz' # OK (this would be treated as use before define) | ||
k: TypeAlias = 'k | None' # False negative in type checking block | ||
l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) | ||
m: TypeAlias = ('int' # TC008 | ||
| None) | ||
n: TypeAlias = ('int' # TC008 (fix removes comment currently) | ||
' | None') | ||
|
||
|
||
class Baz: ... |
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
Oops, something went wrong.