mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-05 08:00:27 +00:00
![]() This fixes our logic for binding a legacy typevar with its binding context. (To recap, a legacy typevar starts out "unbound" when it is first created, and each time it's used in a generic class or function, we "bind" it with the corresponding `Definition`.) We treat `typing.Self` the same as a legacy typevar, and so we apply this binding logic to it too. Before, we were using the enclosing class as its binding context. But that's not correct — it's the method where `typing.Self` is used that binds the typevar. (Each invocation of the method will find a new specialization of `Self` based on the specific instance type containing the invoked method.) This required plumbing through some additional state to the `in_type_expression` method. This also revealed that we weren't handling `Self`-typed instance attributes correctly (but were coincidentally not getting the expected false positive diagnostics). |
||
---|---|---|
.. | ||
annotated.md | ||
any.md | ||
callable.md | ||
deferred.md | ||
int_float_complex.md | ||
invalid.md | ||
literal.md | ||
literal_string.md | ||
never.md | ||
new_types.md | ||
optional.md | ||
self.md | ||
starred.md | ||
stdlib_typing_aliases.md | ||
string.md | ||
union.md | ||
unsupported_special_forms.md | ||
unsupported_special_types.md | ||
unsupported_type_qualifiers.md |