Skip to content

calling items() on Union of Dicts variable claims the return value is not iterable #3240

Closed
@tjltjl

Description

@tjltjl

The code

    x : Union[Dict[int, int], Dict[str, str]] = dict(a='b')
    for a, b in x.items():
        print(a, b)

yields

error: 'Union[Tuple[builtins.int*, builtins.int*], Tuple[builtins.str*, builtins.str*]]' object is not iterable

Using just Dict[str, str] instead of the Union passes.

The code (naturally) runs in python, and both elements in the union are iterable...

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions