I am trying to annotate a function which receives a tuple of types, and returns a value of one of the provided types.
For example:
@overload
def func[T1](types: tuple[type[T1]]) -> T1: ...
@overload
def func[T1, T2](types: tuple[type[T1], type[T2]]) -> T1 | T2: ...
@overload
def func[T1, T2, T3](types: tuple[type[T1], type[T2], type[T3]]) -> T1 | T2 | T3: ...
Conceptually analogous to the following invalid code:
# invalid
def func[*Ts](types: tuple[type[*Ts]]) -> Union[*Ts]: ...
Is something like this supported?
tupleand notcollections.abc.Collection? There's rarely a reason not to allow any kind of collection.