Skip to content

docstring-missing-returns (DOC201) reports on __new__ #13079

@tjkuson

Description

@tjkuson

Running ruff check --select DOC201 --preview --isolated on

class Foo:
    def __new__(cls, x: int) -> "Foo":
        """A very helpful docstring.

        Args:
            x: An integer.
        """
        ...  # Do something with x.
        return super().__new__(cls)

reports a docstring-missing-returns (DOC201) diagnostic.

The expected behaviour is that the return value of a __new__ method is not expected to be documented as it simply returns an instance of the class.

Related to #8085

Search terms: DOC201, docstring-missing-returns, __new__

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstringRelated to docstring linting or formattingneeds-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions