mypy
1d6905a7 - Fix various bugs in TypeVarTuples with defaults (#21544)

Commit
42 days ago
Fix various bugs in TypeVarTuples with defaults (#21544) Fixes a bunch of TODOs in tests. Fixes https://github.com/python/mypy/issues/20449 Couple non-trivial things here: First, I prohibit (regular) type variables with defaults that appear after a `TypeVarTuple`. The PEP and the spec are clear that these are ambiguous and invalid. But, because they are ambiguous, we can't simply give the error, since otherwise various parts of code will behave in weirdly inconsistent ways. Therefore, I completely erase ambiguous type variables out of existence, 1984 style. Second, couple commented-out tests cases suggested that `TypeVarTuple` defaults should be used in cases where `*tuple[()]` would be used as a value otherwise, plus `Foo[X, Y]` and `Foo[X, Y, *tuple[()]]` should be interpreted differently. I don't see anything about this in the PEP/spec, and I don't like this. I think the default should be used _only_ in cases where `Any` or `Never` would be used otherwise.
Author
Parents
Loading