|
| 1 | +--- |
| 2 | +source: crates/ruff_linter/src/rules/pyflakes/mod.rs |
| 3 | +--- |
| 4 | +F821_26.py:9:33: F821 Undefined name `CStr` |
| 5 | + | |
| 6 | + 8 | # Forward references: |
| 7 | + 9 | MaybeCStr: TypeAlias = Optional[CStr] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 8 | + | ^^^^ F821 |
| 9 | +10 | MaybeCStr2: TypeAlias = Optional["CStr"] # always okay |
| 10 | +11 | CStr: TypeAlias = Union[C, str] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 11 | + | |
| 12 | + |
| 13 | +F821_26.py:11:25: F821 Undefined name `C` |
| 14 | + | |
| 15 | + 9 | MaybeCStr: TypeAlias = Optional[CStr] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 16 | +10 | MaybeCStr2: TypeAlias = Optional["CStr"] # always okay |
| 17 | +11 | CStr: TypeAlias = Union[C, str] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 18 | + | ^ F821 |
| 19 | +12 | CStr2: TypeAlias = Union["C", str] # always okay |
| 20 | + | |
| 21 | + |
| 22 | +F821_26.py:16:12: F821 Undefined name `C` |
| 23 | + | |
| 24 | +14 | # References to a class from inside the class: |
| 25 | +15 | class C: |
| 26 | +16 | other: C = ... # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 27 | + | ^ F821 |
| 28 | +17 | other2: "C" = ... # always okay |
| 29 | +18 | def from_str(self, s: str) -> C: ... # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 30 | + | |
| 31 | + |
| 32 | +F821_26.py:18:35: F821 Undefined name `C` |
| 33 | + | |
| 34 | +16 | other: C = ... # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 35 | +17 | other2: "C" = ... # always okay |
| 36 | +18 | def from_str(self, s: str) -> C: ... # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 37 | + | ^ F821 |
| 38 | +19 | def from_str2(self, s: str) -> "C": ... # always okay |
| 39 | + | |
| 40 | + |
| 41 | +F821_26.py:23:10: F821 Undefined name `B` |
| 42 | + | |
| 43 | +21 | # Circular references: |
| 44 | +22 | class A: |
| 45 | +23 | foo: B # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 46 | + | ^ F821 |
| 47 | +24 | foo2: "B" # always okay |
| 48 | +25 | bar: dict[str, B] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 49 | + | |
| 50 | + |
| 51 | +F821_26.py:25:20: F821 Undefined name `B` |
| 52 | + | |
| 53 | +23 | foo: B # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 54 | +24 | foo2: "B" # always okay |
| 55 | +25 | bar: dict[str, B] # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 56 | + | ^ F821 |
| 57 | +26 | bar2: dict[str, "A"] # always okay |
| 58 | + | |
| 59 | + |
| 60 | +F821_26.py:33:17: F821 Undefined name `Tree` |
| 61 | + | |
| 62 | +32 | class Leaf: ... |
| 63 | +33 | class Tree(list[Tree | Leaf]): ... # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 64 | + | ^^^^ F821 |
| 65 | +34 | class Tree2(list["Tree | Leaf"]): ... # always okay |
| 66 | + | |
| 67 | + |
| 68 | +F821_26.py:39:11: F821 Undefined name `foo` |
| 69 | + | |
| 70 | +37 | class MyClass: |
| 71 | +38 | foo: int |
| 72 | +39 | bar = foo # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 73 | + | ^^^ F821 |
| 74 | +40 | bar = "foo" # always okay |
| 75 | + | |
| 76 | + |
| 77 | +F821_26.py:43:8: F821 Undefined name `baz` |
| 78 | + | |
| 79 | +42 | baz: MyClass |
| 80 | +43 | eggs = baz # valid in a `.pyi` stub file, not in a `.py` runtime file |
| 81 | + | ^^^ F821 |
| 82 | +44 | eggs = "baz" # always okay |
| 83 | + | |
0 commit comments