Filipe - yes, that's right, for your use case `SpecialTuple = Tuple[*Ts]` should work - as long as you don't care about doing e.g. `SpecialTuple[int, ...]`, which currently deliberately doesn't work.
Sorry for the noise, but I just wanted to be sure.
I have a fairly simple use-case: I want to essentially alias Tuple (as in:
SpecialTuple = Tuple) and be able to tell that type apart at runtime.
My users would be able to do:
def some_function() -> SpecialTuple[int, str]:
return 0, 'hi!'
def some_other_function() -> SpecialTuple[int, int, int]:
return 1, 2, 3
And I would be able to know at runtime, by looking at the type annotations, that
the return value is special and I need to do some custom handling. As far as
type checkers would be concerned, SpecialTuple is just a Tuple.
As far as I can tell, this should be possible with the current PEP by doing the
_Ts = TypeVarTuple('_Ts')
SpecialTuple = Tuple[*_TS]
Typing-sig mailing list -- email@example.com
To unsubscribe send an email to firstname.lastname@example.org
Member address: email@example.com