Bug Report
For loops in Python require only an iterable, for which an iterator is subsequently created. However, in the code below, Mypy incorrectly requires __next__ to be available on the iterable.
To Reproduce
from collections.abc import Iterable
xs: zip[tuple[object, ...]] | Iterable[object] = zip(*[[0], [0]])
for x in xs: pass
Actual Behavior
main.py:4: error: "Iterable[object]" has no attribute "__next__" [attr-defined]
Your Environment
- Mypy version used: 1.8.0.
- Mypy command-line flags: None.
- Mypy configuration options from
mypy.ini (and other config files): None.
- Python version used: 3.12.
This is a regression from version 0.942.
1.8.0 Playground
0.942 Playground
Bug Report
For loops in Python require only an iterable, for which an iterator is subsequently created. However, in the code below, Mypy incorrectly requires
__next__to be available on the iterable.To Reproduce
Actual Behavior
Your Environment
mypy.ini(and other config files): None.This is a regression from version 0.942.
1.8.0 Playground
0.942 Playground