[Python] How to transform callable argument types?

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    Assume I have a callable type with some arbitrary set of argument types:

    Callable[[T1, T2, T3, <etc>, Tn], str]


    Is there a way (presumably using TypeVarTuple or ParamSpec) to statically generate the following callable type from it?

    Callable[[T1 | Iterable[T1], T2 | Iterable[T2], T3 | Iterable[T3], <etc>, Tn | Iterable[Tn]], str]

    Continue reading...

Compartilhe esta Página