ruff/crates/ty_python_semantic/resources/mdtest/loops/iterators.md
2025-05-03 19:49:15 +02:00

357 B

Iterators

Yield must be iterable

class NotIterable: ...

class Iterator:
    def __next__(self) -> int:
        return 42

class Iterable:
    def __iter__(self) -> Iterator:
        return Iterator()

def generator_function():
    yield from Iterable()
    yield from NotIterable()  # error: "Object of type `NotIterable` is not iterable"