Skip to content

Empty variadic tuple subtype not assignable to tuple[int, ...] #19110

Description

@jorenham
classShape[*Ts](tuple[*Ts]): ...
classShape0(Shape[()]): ...
classShape1(Shape[int]): ...
defrank(shape: tuple[int, ...]) ->int:
returnlen(shape)
_=rank(Shape()) # ✅_=rank(()) # ✅_=rank(Shape0()) # ❌ Argument 1 to "rank" has incompatible type "Shape0"; expected "tuple[int, ...]"_=rank(Shape1([1])) # ✅

playground

Perhaps this is related to #19105, which also involves empty tuple subtypes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions