ruff/crates/ty_python_semantic/src
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
..
module_resolver Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
semantic_index Fix typos (#17988) 2025-05-09 14:57:14 -04:00
types [ty] Induct into instances and subclasses when finding and applying generics (#18052) 2025-05-12 21:53:11 -04:00
util Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ast_node_ref.rs Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
db.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
dunder_all.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
lib.rs [ty] Add support for __all__ (#17856) 2025-05-07 21:42:42 +05:30
lint.rs [ty] Ignore possibly-unresolved-reference by default (#17934) 2025-05-08 17:44:56 +02:00
list.rs Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
module_name.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
node_key.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
program.rs Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
python_platform.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
semantic_index.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
semantic_model.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
site_packages.rs [ty] Do not allow invalid virtual environments from discovered .venv or VIRTUAL_ENV (#18003) 2025-05-10 20:36:12 +00:00
suppression.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
symbol.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
types.rs [ty] Induct into instances and subclasses when finding and applying generics (#18052) 2025-05-12 21:53:11 -04:00
unpack.rs [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00