Skip to content

zip: add some overloads for heterogeneous tuples #3830

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

Merged
merged 3 commits into from
May 4, 2020

Conversation

hauntsaninja
Copy link
Collaborator

Technically this is a lie, since we return a heterogeneous iterator, not
a tuple. But since we don't have a way of typing heterogeneous
iterators, this is the best we can do.

Fixes python/mypy#8454

Technically this is a lie, since we return a heterogeneous iterator, not
a tuple. But since we don't have a way of typing heterogeneous
iterators, this is the best we can do.

Fixes python/mypy#8454
@JelleZijlstra
Copy link
Member

Could you fix the various CI failures?

@hauntsaninja
Copy link
Collaborator Author

Suspected we'd see some issues. I think the best option here is to type ignore...

@hauntsaninja
Copy link
Collaborator Author

Gentle bump!

@JelleZijlstra JelleZijlstra merged commit e857ad6 into python:master May 4, 2020
@hauntsaninja hauntsaninja deleted the zip branch May 4, 2020 04:23
@ilevkivskyi
Copy link
Member

Technically this is a lie

It looks like this needs to be reverted because lies break mypyc, see CI failure (unless @msullivan has an idea for workaround).

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented May 5, 2020

Would changing the return type to Union[Any, <...>] work?

Looks like we'd remain able to catch errors like:

from typing import *
strs, nums = zip(*[("zz", 1), ("yyy", 8)])
nums[0] + "asdf"

@ilevkivskyi
Copy link
Member

For now we are using cast(Any, zip) just to unblock the situation, see python/mypy#8780. But we need to find a better long-term solution.

hauntsaninja pushed a commit to hauntsaninja/typeshed that referenced this pull request Jun 21, 2020
JelleZijlstra pushed a commit that referenced this pull request Jun 25, 2020
)

This reverts commit e857ad6.

Co-authored-by: hauntsaninja <>
@hauntsaninja
Copy link
Collaborator Author

Note, this was reverted in #4254

vishalkuo pushed a commit to vishalkuo/typeshed that referenced this pull request Jun 26, 2020
Technically this is a lie, since we return a heterogeneous iterator, not
a tuple. But since we don't have a way of typing heterogeneous
iterators, this is the best we can do.

Fixes python/mypy#8454
vishalkuo pushed a commit to vishalkuo/typeshed that referenced this pull request Jun 26, 2020
…" (python#4254)

This reverts commit e857ad6.

Co-authored-by: hauntsaninja <>
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.

Failure to correctly infer tuple type through zip
3 participants