-
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.
[
pyflakes
] Ignore errors in @no_type_check
string annotations (`F…
…722`, `F821`) (#15215)
- Loading branch information
1 parent
835b453
commit 6180f78
Showing
10 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_32.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,8 @@ | ||
from datetime import datetime | ||
from typing import no_type_check | ||
|
||
|
||
# No errors | ||
|
||
@no_type_check | ||
def f(a: datetime, b: "datetime"): ... |
16 changes: 16 additions & 0 deletions
16
crates/ruff_linter/resources/test/fixtures/pyflakes/F722_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,16 @@ | ||
from typing import no_type_check | ||
|
||
|
||
# Errors | ||
|
||
@no_type_check | ||
class C: | ||
def f(self, arg: "this isn't python") -> "this isn't python either": | ||
x: "this also isn't python" = 1 | ||
|
||
|
||
# No errors | ||
|
||
@no_type_check | ||
def f(arg: "this isn't python") -> "this isn't python either": | ||
x: "this also isn't python" = 0 |
16 changes: 16 additions & 0 deletions
16
crates/ruff_linter/resources/test/fixtures/pyflakes/F821_31.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 @@ | ||
import typing | ||
|
||
|
||
# Errors | ||
|
||
@typing.no_type_check | ||
class C: | ||
def f(self, arg: "B") -> "S": | ||
x: "B" = 1 | ||
|
||
|
||
# No errors | ||
|
||
@typing.no_type_check | ||
def f(arg: "A") -> "R": | ||
x: "A" = 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
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
5 changes: 5 additions & 0 deletions
5
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_32.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,5 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
snapshot_kind: text | ||
--- | ||
|
29 changes: 29 additions & 0 deletions
29
...ter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722_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,29 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
snapshot_kind: text | ||
--- | ||
F722_1.py:8:22: F722 Syntax error in forward annotation: `this isn't python` | ||
| | ||
6 | @no_type_check | ||
7 | class C: | ||
8 | def f(self, arg: "this isn't python") -> "this isn't python either": | ||
| ^^^^^^^^^^^^^^^^^^^ F722 | ||
9 | x: "this also isn't python" = 1 | ||
| | ||
|
||
F722_1.py:8:46: F722 Syntax error in forward annotation: `this isn't python either` | ||
| | ||
6 | @no_type_check | ||
7 | class C: | ||
8 | def f(self, arg: "this isn't python") -> "this isn't python either": | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ F722 | ||
9 | x: "this also isn't python" = 1 | ||
| | ||
|
||
F722_1.py:9:12: F722 Syntax error in forward annotation: `this also isn't python` | ||
| | ||
7 | class C: | ||
8 | def f(self, arg: "this isn't python") -> "this isn't python either": | ||
9 | x: "this also isn't python" = 1 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ F722 | ||
| |
53 changes: 53 additions & 0 deletions
53
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_31.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,53 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
snapshot_kind: text | ||
--- | ||
F821_31.py:8:23: F821 Undefined name `B` | ||
| | ||
6 | @typing.no_type_check | ||
7 | class C: | ||
8 | def f(self, arg: "B") -> "S": | ||
| ^ F821 | ||
9 | x: "B" = 1 | ||
| | ||
|
||
F821_31.py:8:31: F821 Undefined name `S` | ||
| | ||
6 | @typing.no_type_check | ||
7 | class C: | ||
8 | def f(self, arg: "B") -> "S": | ||
| ^ F821 | ||
9 | x: "B" = 1 | ||
| | ||
|
||
F821_31.py:9:13: F821 Undefined name `B` | ||
| | ||
7 | class C: | ||
8 | def f(self, arg: "B") -> "S": | ||
9 | x: "B" = 1 | ||
| ^ F821 | ||
| | ||
|
||
F821_31.py:15:13: F821 Undefined name `A` | ||
| | ||
14 | @typing.no_type_check | ||
15 | def f(arg: "A") -> "R": | ||
| ^ F821 | ||
16 | x: "A" = 1 | ||
| | ||
|
||
F821_31.py:15:21: F821 Undefined name `R` | ||
| | ||
14 | @typing.no_type_check | ||
15 | def f(arg: "A") -> "R": | ||
| ^ F821 | ||
16 | x: "A" = 1 | ||
| | ||
|
||
F821_31.py:16:9: F821 Undefined name `A` | ||
| | ||
14 | @typing.no_type_check | ||
15 | def f(arg: "A") -> "R": | ||
16 | x: "A" = 1 | ||
| ^ F821 | ||
| |
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