You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If Ts is a TypeVarTuple, using it in a generic type Foo will be equivalent to applying Foo to every component of the tuple. I.e. Foo[Ts] will be logically equivalent to (Foo[T1], Foo[T2], ...) where T1, T2 are the components of the tuple. Foo[Ts] itself will be treated like a TypeVarTuple, except that its components are not plain type variables, but an application of Foo.
Pitch
This will help giving better types to zip-like functions. Currently, these functions are typed using @overload, for example:
This is very verbose and error-prone, and also introduces an arbitrary limit for the number of arguments. (typeshed stubs support up to 6 arguments for map and zip and up to 10 for itertools.product.)
With the proposed feature these can be typed simply as:
A feature like this would likely require a PEP and an update to the Python typing spec. The Python typing forum would be a good place to discuss the idea.
A related idea was proposed here if you're interested in commenting (or collaborating) on that proposal.
Feature
If
Ts
is aTypeVarTuple
, using it in a generic typeFoo
will be equivalent to applyingFoo
to every component of the tuple. I.e.Foo[Ts]
will be logically equivalent to(Foo[T1], Foo[T2], ...)
whereT1
,T2
are the components of the tuple.Foo[Ts]
itself will be treated like aTypeVarTuple
, except that its components are not plain type variables, but an application ofFoo
.Pitch
This will help giving better types to
zip
-like functions. Currently, these functions are typed using@overload
, for example:This is very verbose and error-prone, and also introduces an arbitrary limit for the number of arguments. (typeshed stubs support up to 6 arguments for
map
andzip
and up to 10 foritertools.product
.)With the proposed feature these can be typed simply as:
The text was updated successfully, but these errors were encountered: