---
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
---
F821 Undefined name `DoesNotExist`
  --> F821_17.py:16:12
   |
14 | # Types used in aliased assignment must exist
15 |
16 | type Foo = DoesNotExist  # F821: Undefined name `DoesNotExist`
   |            ^^^^^^^^^^^^
17 | type Foo = list[DoesNotExist]  # F821: Undefined name `DoesNotExist`
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:17:17
   |
16 | type Foo = DoesNotExist  # F821: Undefined name `DoesNotExist`
17 | type Foo = list[DoesNotExist]  # F821: Undefined name `DoesNotExist`
   |                 ^^^^^^^^^^^^
18 |
19 | # Type parameters do not escape alias scopes
   |

F821 Undefined name `T`
  --> F821_17.py:22:1
   |
21 | type Foo[T] = T
22 | T  # F821: Undefined name `T` - not accessible afterward alias scope
   | ^
23 |
24 | # Type parameters in functions
   |

F821 Undefined name `T`
  --> F821_17.py:39:17
   |
37 | from some_library import some_decorator
38 |
39 | @some_decorator(T)  # F821: Undefined name `T` - not accessible in decorators
   |                 ^
40 |
41 | def foo[T](t: T) -> None: ...
   |

F821 Undefined name `T`
  --> F821_17.py:42:1
   |
41 | def foo[T](t: T) -> None: ...
42 | T  # F821: Undefined name `T` - not accessible afterward function scope
   | ^
   |

F821 Undefined name `T`
  --> F821_17.py:64:17
   |
63 | from some_library import some_decorator
64 | @some_decorator(T)  # F821: Undefined name `T` - not accessible in decorators
   |                 ^
65 |
66 | class Foo[T](list[T]): ...
   |

F821 Undefined name `T`
  --> F821_17.py:67:1
   |
66 | class Foo[T](list[T]): ...
67 | T  # F821: Undefined name `T` - not accessible after class scope
   | ^
68 |
69 | # Types specified in bounds should exist
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:71:13
   |
69 | # Types specified in bounds should exist
70 |
71 | type Foo[T: DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
   |             ^^^^^^^^^^^^
72 | def foo[T: DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
73 | class Foo[T: DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:72:12
   |
71 | type Foo[T: DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
72 | def foo[T: DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
   |            ^^^^^^^^^^^^
73 | class Foo[T: DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:73:14
   |
71 | type Foo[T: DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
72 | def foo[T: DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
73 | class Foo[T: DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |              ^^^^^^^^^^^^
74 |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:75:14
   |
73 | class Foo[T: DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
74 |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |              ^^^^^^^^^^^^^
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:75:29
   |
73 | class Foo[T: DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
74 |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                             ^^^^^^^^^^^^^
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:76:13
   |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |             ^^^^^^^^^^^^^
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:76:28
   |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                            ^^^^^^^^^^^^^
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:77:15
   |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |               ^^^^^^^^^^^^^
78 |
79 | # Same in defaults
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:77:30
   |
75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                              ^^^^^^^^^^^^^
78 |
79 | # Same in defaults
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:81:14
   |
79 | # Same in defaults
80 |
81 | type Foo[T = DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
   |              ^^^^^^^^^^^^
82 | def foo[T = DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
83 | class Foo[T = DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:82:13
   |
81 | type Foo[T = DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
82 | def foo[T = DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
   |             ^^^^^^^^^^^^
83 | class Foo[T = DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |

F821 Undefined name `DoesNotExist`
  --> F821_17.py:83:15
   |
81 | type Foo[T = DoesNotExist] = T  # F821: Undefined name `DoesNotExist`
82 | def foo[T = DoesNotExist](t: T) -> T: return t  # F821: Undefined name `DoesNotExist`
83 | class Foo[T = DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
   |               ^^^^^^^^^^^^
84 |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:85:15
   |
83 | class Foo[T = DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
84 |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |               ^^^^^^^^^^^^^
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:85:30
   |
83 | class Foo[T = DoesNotExist](list[T]): ...  # F821: Undefined name `DoesNotExist`
84 |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                              ^^^^^^^^^^^^^
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:86:14
   |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
   |              ^^^^^^^^^^^^^
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:86:29
   |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
   |                             ^^^^^^^^^^^^^
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |

F821 Undefined name `DoesNotExist1`
  --> F821_17.py:87:16
   |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                ^^^^^^^^^^^^^
88 |
89 | # Type parameters in nested classes
   |

F821 Undefined name `DoesNotExist2`
  --> F821_17.py:87:31
   |
85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist…
87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ...  # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2`
   |                               ^^^^^^^^^^^^^
88 |
89 | # Type parameters in nested classes
   |

F821 Undefined name `t`
   --> F821_17.py:102:52
    |
100 |             return x
101 |
102 |         def cannot_access_parent_variable(self, x: t) -> t:  # F821: Undefined name `T`
    |                                                    ^
103 |                 t # F821: Undefined name `t`
104 |                 return x
    |

F821 Undefined name `t`
   --> F821_17.py:102:58
    |
100 |             return x
101 |
102 |         def cannot_access_parent_variable(self, x: t) -> t:  # F821: Undefined name `T`
    |                                                          ^
103 |                 t # F821: Undefined name `t`
104 |                 return x
    |

F821 Undefined name `t`
   --> F821_17.py:103:17
    |
102 |         def cannot_access_parent_variable(self, x: t) -> t:  # F821: Undefined name `T`
103 |                 t # F821: Undefined name `t`
    |                 ^
104 |                 return x
    |

F821 Undefined name `T`
   --> F821_17.py:116:40
    |
116 | def cannot_access_in_default[T](t: T = T):  # F821
    |                                        ^
117 |     pass
    |
