Skip to content

missing-yields

Part of: Enrichment Check

Check enrichment
Category required
Applies to functions, methods
Since v1.0.0

Generator yields values but has no Yields section

What it detects

This rule flags generator functions that contain yield or yield from statements but have no Yields: section in their docstring.

Why is this a problem?

Consumers of the generator don't know what values it produces. Without a Yields: section, callers must read the source code to understand the iteration contract. API documentation generated by mkdocstrings will also lack yield information, making the generator's interface opaque.

Example

def stream_results(query: str) -> Iterator[dict]:
    """Stream database results for a query.

    Args:
        query: SQL query string.
    """
    for row in db.execute(query):
        yield dict(row)
def stream_results(query: str) -> Iterator[dict]:
    """Stream database results for a query.

    Args:
        query: SQL query string.

    Yields:
        Row data as a dictionary with column names as keys.
    """
    for row in db.execute(query):
        yield dict(row)