Skip to content

<nothing> object is not iterable #4330

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

Open
carljm opened this issue Dec 6, 2017 · 0 comments
Open

<nothing> object is not iterable #4330

carljm opened this issue Dec 6, 2017 · 0 comments
Labels
bug mypy got something wrong

Comments

@carljm
Copy link
Member

carljm commented Dec 6, 2017

This code:

d = {k: v for k, v in []}

gives

nothingiterable.py:1: error: '<nothing>' object is not iterable

(The real code this was derived from had vals or [], not just [], and mypy had concluded that vals was of type None, for unrelated bogus reasons).

I realize mypy doesn't know the type of list elements for an empty list, but it seems like in the case of an empty list literal it would be possible to realize that it doesn't matter, and the resulting type of d could be an uninhabited dictionary?

@AlexWaygood AlexWaygood added the bug mypy got something wrong label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants