I want to create a type that is a tuple that contains 5 floats and an int. I can do this in the following way which works nicely.
from typing import Tuple
MyT = Tuple[float, float, float, float, float, int]
t: MyT = (1.0, 1.0, 1.0, 1.0, 1.0, 5)
But if I want even more floats it will become annoying having to type the same over and over. Is there a way to create such a type in a parametrized way? I know that passing a tuple to Tuple[] works as well, i.e.
MyT = Tuple[(float, float, float, float, float, int)]
t: MyT = (1.0, 1.0, 1.0, 1.0, 1.0, 5)
Therefore, I tried the following.
tup = ((float, ) * 5) + (int, )
MyT = Tuple[tup]
t: MyT = (1.0, 1.0, 1.0, 1.0, 1.0, 5)
But this fails type checking with mypy. I guess it is because the tuple that is passed to Tuple[] is created only at runtime? Is there a similar way that would work? Tested using Python 3.8.6 and MyPy 0.782.