Files
Charlie Marsh b6a2ae6a70 [ty] Reject defaulted TypeVars after a TypeVarTuple in legacy generic classes (#29753)
## Summary

We now report a defaulted `TypeVar` anywhere after a `TypeVarTuple` in a
legacy `Generic[...]` or `Protocol[...]` base. The ambiguity persists
when a required parameter comes between them.

```python
from typing import Generic, TypeVar, TypeVarTuple

Ts = TypeVarTuple("Ts")
U = TypeVar("U")
T = TypeVar("T", default=bool)

class C(Generic[*Ts, U, T]): ...  # Now an error on T
```

For `C[int, str]`, an empty `Ts` leaves `U = int` and `T = str`. Binding
`int` to `Ts` instead leaves `U = str` and uses the default `T = bool`.
The typing spec describes the adjacent case. We also diagnose the
nonadjacent case, as mypy, Pyright, and Pyrefly do. [Typing
spec](https://typing.python.org/en/latest/spec/generics.html#defaults-following-typevartuple)

Legacy bases and PEP 695 declarations now share a diagnostic that points
to the pack and each later defaulted `TypeVar`. Both allow a defaulted
`ParamSpec`, whose argument list is distinguishable from the types that
fill the pack.
2026-10-28 01:45:38 +00:00
..
2025-05-03 19:49:15 +02:00

Markdown files within the mdtest/ subdirectory are tests of type inference and type checking; executed by the tests/mdtest.rs integration test.

See crates/ty_test/README.md for documentation of this test format.