Skip to content
This repository has been 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 opened this issue Apr 15, 2020 · 1 comment · May be fixed by #556
Open

Spurious D401 when docstring only contains a Returns section #463

anntzer opened this issue Apr 15, 2020 · 1 comment · May be fixed by #556
Labels
Waiting for Assignee This issue has been triaged as a good idea, waiting for a volunteer to implement

Comments

@anntzer
Copy link
Contributor

anntzer commented Apr 15, 2020

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?)

@Nurdok Nurdok added the Waiting for Assignee This issue has been triaged as a good idea, waiting for a volunteer to implement label Apr 24, 2020
@Nurdok
Copy link
Member

Nurdok commented Apr 24, 2020

Seems like a bug. PRs welcome :)

@sambhav sambhav added this to the pydocstyle 6.0 milestone Aug 23, 2020
@anntzer anntzer linked a pull request Nov 10, 2021 that will close this issue
2 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Waiting for Assignee This issue has been triaged as a good idea, waiting for a volunteer to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants