Skip to content

Not behaving correctly in zipped loops #7004

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

Closed
guillemglez opened this issue Jun 17, 2019 · 1 comment
Closed

Not behaving correctly in zipped loops #7004

guillemglez opened this issue Jun 17, 2019 · 1 comment

Comments

@guillemglez
Copy link

This code runs just fine:

for letter, integer_tuple in zip(("a", "b"), ((1, 2), (3, 4, 5))):
    for integer in integer_tuple:
        print(letter, integer)

And output is as expected:

a 1
a 2
b 3
b 4
b 5

Although mypy complains about integer_tuple not being an iterable:

fk.py:2: error: "object" has no attribute "__iter__"; maybe "__str__" or "__dir__"? (not iterable)

Note that this only happens if the second interable in zip contains two iterables with different lengths, but not if they are both the same, i.e. ((1, 2), (3, 4)) does not raise any error from mypy .

Using Python 3.6.8 and mypy 0.701

@ilevkivskyi
Copy link
Member

Duplicate of #4975 (already high priority).

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

No branches or pull requests

2 participants