-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
zip vararg #10651
Comments
I think the problem with inferring the number of elements in each tuple is that mypy is that we don't track the length of lists in general. In your simplified example we could determine the length of the list since it's a literal, but a fairly straightforward workaround is using a tuple instead:
Supporting the general case well enough to support the code you linked would probably involve some form of https://peps.python.org/pep-0646/#shape-arithmetic to track the length of the input list across calls. The revealed type including |
Pranav is correct. The remaining inference issue he mentions can be improved in typeshed, transferring the issue there. |
mypy 0.950 (compiled: yes) and Python 3.10.4:
Any chance to get mypy infer the type of
zip(*l)
?Thanks for reading!
For the story it comes from here https://github.com/joelgrus/data-science-from-scratch/blob/d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1/first-edition/code-python3/machine_learning.py#L18 !
The text was updated successfully, but these errors were encountered: