zip vararg
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
mypy 0.950 (compiled: yes) and Python 3.10.4:
z1 = list(zip((1, 10), (2, 20), (3, 30))) # correct: list[Tuple[int, int, int]]
z2 = list(zip(*[(1, 10), (2, 20), (3, 30)])) # list[tuple[Any, ...]] but I expect list[tuple[int, int, int]]
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 !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the examples with mypy 0.950 and Python 3.10.4, including the machine_learning.py example at the linked line. Investigate how the zip(*l) expression is typed and compare it with the direct zip call; done means the inferred result matches the expected tuple element types without introducing incorrect behavior for other zip calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100