Skip to content

<nothing> object is not iterable #4330

Open
@carljm

Description

@carljm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions