Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Spurious D401 when docstring only contains a Returns section #463

Open
@anntzer

Description

@anntzer

With

class T:
    def get_x(self):
        """
        Returns
        -------
        int
            The x.
        """
        return self.x

pydocstyle currently warns (in particular)

/tmp/test.py:3 in public method `get_x`:
        D205: 1 blank line required between summary line and description (found 0)
/tmp/test.py:3 in public method `get_x`:
        D400: First line should end with a period (not 's')
/tmp/test.py:3 in public method `get_x`:
        D401: First line should be in imperative mood (perhaps 'Return', not 'Returns')

The first two warnings are reasonable (they are effectively saying "you are missing a summary line" -- a single warning for that would be nicer but things are fine as is), but the last one is spurious: one should be able to disable D205/D400 to allow docstrings without a single summary line while keeping the check for imperative mood when a summary line is present. (pydocstyle already checks for sections in the docstring, so I guess it could just disable D401 when it detects that the first line is indeed a section title?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Waiting for AssigneeThis issue has been triaged as a good idea, waiting for a volunteer to implement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions