Skip to content

Is there a way to be generic over the parameters of a generic type? #1634

Answered by TeamSpen210
fjarri asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately no. First, something like Union[...] isn't valid to pass to a function accepting type - that only accepts actual classes. The solution to that is likely a new typing construct - TypeForm. The PEP for that is still in draft stage though. Secondly Union[*Ts] isn't supported itself. This was mentioned in early versions of the TypeVarTuple PEP, but was removed due to the limited number of use cases and implementation complexity required.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fjarri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants