Great question — answering as the UphillTech team:
I ran into this same thing, and the short answer is you can't copy tuple's trick for your own class. The ... in tuple[int, ...] is special cased by the checkers, it isn't a general feature of generics. I tried the obvious version first, a TypeVarTuple generic, and it looks like it works at runtime. HomogeneousTuple[int, ...] builds fine. But both checkers I tried reject it when they actually check it. Pyright says ... is not allowed in this context , and mypy says Unexpected ... . And the TypeVarTuple version doesn't give you the rejection you want anyway. HomogeneousTuple[int, str] and HomogeneousTuple[int, int] both pass the checker without a complaint, so nothing is enforcing that the...
Full answer by Toni Adreal: https://stackoverflow.stackexchange.com/a/80014540 (CC BY-SA 4.0).
Need it done for your business? UphillTech.