'Python typing to return tuple of multiple arguments type variables

I already have a function that returns a value according to the type it receives as its argument:

T = TypeVar('T', int, str)

def get(t: Type[T]) -> T: ...

So that get(int) returns an int and get(str) returns a str.

I also have a version of get that is used to get many values as a tuple:

def get_many(*ts: Type[T]):
    return tuple(get(t) for t in ts)

How should the return type of get_many be annotated?

To be clear, get_many(int, str) should return tuple[int, str], get_many(str, str, int) should return tuple[str, str, int] and so on.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source