mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
[pyflakes] Avoid false positives in @no_type_check
contexts (F821, F722) (#14615)
This commit is contained in:
parent
b94d6cf567
commit
9f446faa6c
9 changed files with 136 additions and 3 deletions
21
crates/ruff_linter/resources/test/fixtures/pyflakes/F722_1.py
vendored
Normal file
21
crates/ruff_linter/resources/test/fixtures/pyflakes/F722_1.py
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""Regression test for #13824.
|
||||
|
||||
Don't report an error when the function being annotated has the
|
||||
`@no_type_check` decorator.
|
||||
|
||||
However, we still want to ignore this annotation on classes. See
|
||||
https://github.com/python/typing/pull/1615/files and the discussion on #14615.
|
||||
"""
|
||||
|
||||
from typing import no_type_check
|
||||
|
||||
|
||||
@no_type_check
|
||||
def f(arg: "this isn't python") -> "this isn't python either":
|
||||
x: "this also isn't python" = 0
|
||||
|
||||
|
||||
@no_type_check
|
||||
class C:
|
||||
def f(arg: "this isn't python") -> "this isn't python either":
|
||||
x: "this also isn't python" = 1
|
21
crates/ruff_linter/resources/test/fixtures/pyflakes/F821_30.py
vendored
Normal file
21
crates/ruff_linter/resources/test/fixtures/pyflakes/F821_30.py
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""Regression test for #13824.
|
||||
|
||||
Don't report an error when the function being annotated has the
|
||||
`@no_type_check` decorator.
|
||||
|
||||
However, we still want to ignore this annotation on classes. See
|
||||
https://github.com/python/typing/pull/1615/files and the discussion on #14615.
|
||||
"""
|
||||
|
||||
import typing
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
def f(arg: "A") -> "R":
|
||||
x: "A" = 1
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
class C:
|
||||
def f(self, arg: "B") -> "S":
|
||||
x: "B" = 1
|
Loading…
Add table
Add a link
Reference in a new issue