ruff/docs/rules/yield-in-init.md
2023-02-10 16:30:36 -05:00

344 B

yield-in-init (PLE0100)

Derived from the Pylint linter.

What it does

Checks for __init__ methods that turned into generators via the presence of yield or yield from statements.

Why is this bad?

Generators are not allowed in __init__ methods.

Example

class Foo:
    def __init__(self):
        yield 1