-
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.
## Summary This rule was added to `flake8-type-checking` as `TC010`. We're about to stabilize it, so we might as well use the correct code. See: #9573.
- Loading branch information
1 parent
c1e6732
commit 28672fe
Showing
12 changed files
with
93 additions
and
91 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH006_1.py
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH006_2.py
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH010_1.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,18 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TypeVar | ||
|
||
|
||
x: "int" | str # TCH010 | ||
x: ("int" | str) | "bool" # TCH010 | ||
|
||
|
||
def func(): | ||
x: "int" | str # OK | ||
|
||
|
||
z: list[str, str | "int"] = [] # TCH010 | ||
|
||
type A = Value["int" | str] # OK | ||
|
||
OldS = TypeVar('OldS', int | 'str', str) # TCH010 |
16 changes: 16 additions & 0 deletions
16
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH010_2.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 typing import TypeVar | ||
|
||
|
||
x: "int" | str # TCH010 | ||
x: ("int" | str) | "bool" # TCH010 | ||
|
||
|
||
def func(): | ||
x: "int" | str # OK | ||
|
||
|
||
z: list[str, str | "int"] = [] # TCH010 | ||
|
||
type A = Value["int" | str] # OK | ||
|
||
OldS = TypeVar('OldS', int | 'str', str) # TCH010 |
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
12 changes: 0 additions & 12 deletions
12
...ts/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TCH006_1.py.snap
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
...ts/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TCH006_2.py.snap
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...ts/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TCH010_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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs | ||
--- | ||
TCH010_1.py:18:30: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
16 | type A = Value["int" | str] # OK | ||
17 | | ||
18 | OldS = TypeVar('OldS', int | 'str', str) # TCH010 | ||
| ^^^^^ TCH010 | ||
| | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
...ts/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TCH010_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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs | ||
--- | ||
TCH010_2.py:4:4: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
4 | x: "int" | str # TCH010 | ||
| ^^^^^ TCH010 | ||
5 | x: ("int" | str) | "bool" # TCH010 | ||
| | ||
|
||
TCH010_2.py:5:5: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
4 | x: "int" | str # TCH010 | ||
5 | x: ("int" | str) | "bool" # TCH010 | ||
| ^^^^^ TCH010 | ||
| | ||
|
||
TCH010_2.py:5:20: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
4 | x: "int" | str # TCH010 | ||
5 | x: ("int" | str) | "bool" # TCH010 | ||
| ^^^^^^ TCH010 | ||
| | ||
|
||
TCH010_2.py:12:20: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
12 | z: list[str, str | "int"] = [] # TCH010 | ||
| ^^^^^ TCH010 | ||
13 | | ||
14 | type A = Value["int" | str] # OK | ||
| | ||
|
||
TCH010_2.py:16:30: TCH010 Invalid string member in `X | Y`-style union type | ||
| | ||
14 | type A = Value["int" | str] # OK | ||
15 | | ||
16 | OldS = TypeVar('OldS', int | 'str', str) # TCH010 | ||
| ^^^^^ TCH010 | ||
| | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.