---
source: crates/red_knot_test/src/lib.rs
expression: snapshot
---
---
mdtest name: for.md - For loops - No `__iter__` method and `__getitem__` is not callable
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 Bad:
4 |     __getitem__: None = None
5 | 
6 | # error: [not-iterable]
7 | for x in Bad():
8 |     reveal_type(x)  # revealed: Unknown
```

# Diagnostics

```
error: lint:not-iterable
 --> /src/mdtest_snippet.py:7:10
  |
6 | # error: [not-iterable]
7 | for x in Bad():
  |          ^^^^^ Object of type `Bad` is not iterable because it has no `__iter__` method and its `__getitem__` attribute has type `None`, which is not callable
8 |     reveal_type(x)  # revealed: Unknown
  |

```

```
info: revealed-type
 --> /src/mdtest_snippet.py:8:5
  |
6 | # error: [not-iterable]
7 | for x in Bad():
8 |     reveal_type(x)  # revealed: Unknown
  |     ^^^^^^^^^^^^^^ Revealed type is `Unknown`
  |

```
