Fix type variable defaults depending on previous variables (#21526)
Fixes https://github.com/python/mypy/issues/19192 Fixes https://github.com/python/mypy/issues/20027 Fixes few TODOs in tests (don't know if there are relevant issues) Closes https://github.com/python/mypy/pull/19382 Core idea is simple: don't do bizarre things :-) More precisely, instead of various in-place modifications (which is a big no-no for types), simply expand defaults iteratively as we build the environment for the type. Couple additional things: * Update defaults in `freshen_function_type_vars()` this is required for consistency when updating `TypeVarId`s. * Use `fix_instance()` in `checkexpr.py` for type applications. This will apply _all_ type arguments in cases like `x = Foo[int](...)`. The PEP and the spec say this is how it should be.
I
Ivan Levkivskyi committed
55ee0bd397e22361aae5fa6d8feb1f2bc140ba5e
Parent: cde4779
Committed by GitHub <noreply@github.com>
on 5/21/2026, 4:55:48 PM