---
source: crates/red_knot_test/src/lib.rs
expression: snapshot
---
---
mdtest name: for.md - For loops - `__iter__` method with a bad signature
mdtest path: crates/red_knot_python_semantic/resources/mdtest/loops/for.md
---

# Python source files

## mdtest_snippet.py

```
 1 | from typing_extensions import reveal_type
 2 | 
 3 | class Iterator:
 4 |     def __next__(self) -> int:
 5 |         return 42
 6 | 
 7 | class Iterable:
 8 |     def __iter__(self, extra_arg) -> Iterator:
 9 |         return Iterator()
10 | 
11 | # error: [not-iterable]
12 | for x in Iterable():
13 |     reveal_type(x)  # revealed: int
```

# Diagnostics

```
error: lint:not-iterable
  --> /src/mdtest_snippet.py:12:10
   |
11 | # error: [not-iterable]
12 | for x in Iterable():
   |          ^^^^^^^^^^ Object of type `Iterable` is not iterable because its `__iter__` method has an invalid signature (expected `def __iter__(self): ...`)
13 |     reveal_type(x)  # revealed: int
   |

```

```
info: revealed-type
  --> /src/mdtest_snippet.py:13:5
   |
11 | # error: [not-iterable]
12 | for x in Iterable():
13 |     reveal_type(x)  # revealed: int
   |     ^^^^^^^^^^^^^^ Revealed type is `int`
   |

```
