Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding any length tuple #409

Closed
wants to merge 2 commits into from
Closed

adding any length tuple #409

wants to merge 2 commits into from

Conversation

barnjamin
Copy link
Contributor

@barnjamin barnjamin commented Jun 21, 2022

While trying to figure out the right way to define a tuple of length >6 I found that the typing_extensions package offers an Unpack for variadic length. This PR appears to do what I want for something like:

@router.method
def random_tuple(a: abi.TupleAny[abi.Uint16, abi.Uint64, abi.Uint64, abi.Uint64, abi.Uint64, abi.Uint64]):
    #...

We may consider removing the TupleN types in favor of this setup

It looks like mypy hates it, TypeVarTuples may not be bound yet either

https://peps.python.org/pep-0646/#variance-type-constraints-and-type-bounds-not-yet-supported

@barnjamin barnjamin requested a review from tzaffi June 21, 2022 13:35
@jasonpaulos
Copy link
Contributor

jasonpaulos commented Jun 21, 2022

The long-term plan is to make the Tuple class use TypeVarTuple, so if typing_extensions provides a TypeVarTuple that is adequate, I'd recommend modifying Tuple instead of introducing a new subclass.

But until mypy supports this feature (python/mypy#12280), we may want to hold off, depending on how bad the mypy errors are.

@barnjamin barnjamin closed this Jun 22, 2022
@ahangsu ahangsu deleted the any-len-tuple branch August 4, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants