Skip to content

False positive DOC405 #126

@ddelange

Description

@ddelange

Hi 👋

The following throws a

164: DOC405: Function `yields` has both "return" and "yield" statements. Please use Generator[YieldType, SendType, ReturnType] as the return type annotation, and put your yield type in YieldType and return type in ReturnType. More details in https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html

false positive. Interestingly, when I remove the Args section from the docstring, the false positive is no longer thrown.

from contextlib import contextmanager


@contextmanager
def yields(db: Optional[int]) -> Iterator[int]:
    """Test a function.

    Args:
        db: the database

    Yields:
        Some stuff.
    """
    if db is not None:
        yield db
        return

    db = ...
    yield db

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions