mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
![]() We were not inducting into instance types and subclass-of types when looking for legacy typevars, nor when apply specializations. This addresses https://github.com/astral-sh/ruff/pull/17832#discussion_r2081502056 ```py from __future__ import annotations from typing import TypeVar, Any, reveal_type S = TypeVar("S") class Foo[T]: def method(self, other: Foo[S]) -> Foo[T | S]: ... # type: ignore[invalid-return-type] def f(x: Foo[Any], y: Foo[Any]): reveal_type(x.method(y)) # revealed: `Foo[Any | S]`, but should be `Foo[Any]` ``` We were not detecting that `S` made `method` generic, since we were not finding it when searching the function signature for legacy typevars. |
||
---|---|---|
.. | ||
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 |