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
{{ message }}
Repository navigation
Allow TypeVarTuple as type argument for subclasses of generic TypedDict #16975
I have a TypedDict class which has TypeVarTuple type argument(s), and that works as I would expect. However, when I try to make a class derived from that base class, I get unexpected errors from mypy. Different errors, actually, depending on whether I use Unpack or the new "star" unpacking syntax.
This all ought to work, though, right?
To Reproduce
# typeddict_typevartuple_310.pyfromcollections.abcimportCallablefromtypingimportGeneric, Tuple, TypedDict, TypeVarfromtyping_extensionsimportTypeVarTuple, UnpackATs=TypeVarTuple('ATs')
RT=TypeVar('RT')
classBaseDict(TypedDict, Generic[Unpack[ATs], RT]):
callback: Callable[[Unpack[ATs]], RT]
arguments: Tuple[Unpack[ATs]]
classDerivedDict(BaseDict[Unpack[ATs], RT]): # E: Unpack is only valid in a variadic positionreturned: RT
Activity
erikkemperman commentedon Mar 1, 2024
By the way, would it be reasonable to expect this to work with
ParamSpectoo?Allow TypeVarTuple as type argument for subclasses of generic TypedDi…
Allow TypeVarTuple as type argument for subclasses of generic TypedDi…