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.
On Sun, 21 Feb 2021 at 05:42, Filipe Laíns email@example.com wrote:
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 following:
_Ts = TypeVarTuple('_Ts') SpecialTuple = Tuple[*_TS]
Thank you, Filipe Laíns _______________________________________________ Typing-sig mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: firstname.lastname@example.org