PEP 696: Type defaults for TypeVarLikes

I don’t think the Map operator would require any syntactic changes under PEP 695, since no change is needed to how type parameters are declared.

The TypeVarDict proposal is not very fleshed out yet, but it seems to me that it could be implemented as a TypeVar with its bound set to TypedDict, plus some new operators like typing.KeyType[] and typing.ValueType[] that would work on TypedDicts. This approach would work under PEP 695 without any further syntactic changes.

You are right in general that enshrining type parameters in the syntax makes it more difficult to change them, and it is unfortunate that PEP 696 is getting delayed for this reason. However, I don’t anticipate too many proposals other than PEP 696 that will really require syntax changes.

I actually think it is good to put a bit of a brake on introducing more kinds of “TypeVarLikes” other than ParamSpec and TypeVarTuple. These two are already among the most complex type system features; mypy doesn’t even fully implement TypeVarTuple yet and there are numerous bugs with the ParamSpec support. We should think very carefully before we add more kinds of type parameters that introduce even more complexity into the type system.

1 Like