ruff
c0b78da5 - [ty] Preserve type variables in bounded generic defaults (#28122)

Commit
26 days ago
[ty] Preserve type variables in bounded generic defaults (#28122) A type parameter default such as `Box[T]` can incorrectly reject `T` when `Box` has a bounded or constrained type parameter, leaving the default specialized with `Unknown`. This change accepts compatible type variables and preserves them so applying the default substitutes the actual type argument. Bind unresolved type variables in a temporary copy when validating generic arguments against bounds or constraints. Keep the original type in the specialization so defaults can still be bound to the generic that uses them. Fixes https://github.com/astral-sh/ty/issues/4408. ## Test plan Added mdtests for defaults containing bounded and constrained type variables in both PEP 695 and legacy generic syntax. The tests cover class and type alias defaults, substitution through nested tuple arguments, incompatible bounds and constraints, and rejection of invariant list arguments.
Author
Parents
Loading