---
source: crates/ty_test/src/lib.rs
expression: snapshot
---
---
mdtest name: for.md - For loops - `__iter__` method with a bad signature
mdtest path: crates/ty_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[not-iterable]: Object of type `Iterable` is not iterable
  --> src/mdtest_snippet.py:12:10
   |
11 | # error: [not-iterable]
12 | for x in Iterable():
   |          ^^^^^^^^^^
13 |     reveal_type(x)  # revealed: int
   |
info: Its `__iter__` method has an invalid signature
info: Expected signature `def __iter__(self): ...`
info: rule `not-iterable` is enabled by default

```

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

```
