BSK-E0120 error

Generator return type and yield type violations

A generator function (one containing yield or yield from) must declare a return type compatible with generator protocols:

- Sync generators: Generator, Iterator, or Iterable - Async generators: AsyncGenerator, AsyncIterator, or AsyncIterable

Additionally, yield expressions must produce values assignable to the declared yield type, and yield from sub-generators must have compatible yield and send types.

from typing import Generator, Iterator

# BAD -- generator with non-generator return type
def bad() -> int:
    yield 1

# GOOD
def good() -> Iterator[int]:
    yield 1

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial BSK-E0120 down per-file or per-path from your editor or pyproject.toml, or fix the code so it type-checks. See the Type System rules and the complete diagnostic reference.

Canonical URL: https://www.basilisk-python.dev/errors/BSK-E0120