ruff/crates/ty_python_semantic/resources/mdtest/generics
Douglas Creager f301931159
[ty] Induct into instances and subclasses when finding and applying generics (#18052)
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.
2025-05-12 21:53:11 -04:00
..
legacy [ty] Induct into instances and subclasses when finding and applying generics (#18052) 2025-05-12 21:53:11 -04:00
pep695 [ty] Induct into instances and subclasses when finding and applying generics (#18052) 2025-05-12 21:53:11 -04:00
builtins.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
scoping.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00