BSK-E0131 error

Generator yield/send/return type mismatch

When a function is annotated with GeneratorY, S, R, IteratorY, or IterableY, the yield expressions must produce values compatible with Y, and yield from expressions must delegate to generators whose yield and send types are compatible.

from typing import Generator, Iterator

class A: ...
class B: ...

def bad() -> Generator[A, None, None]:
    yield 3          # E: incompatible yield type

def bad2() -> Iterator[A]:
    yield B()        # E: incompatible yield type

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial BSK-E0131 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-E0131