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

D413 problems since pydocstyle 4.0.0 #401

Closed
MarkusPiotrowski opened this issue Aug 27, 2019 · 1 comment · Fixed by #404
Closed

D413 problems since pydocstyle 4.0.0 #401

MarkusPiotrowski opened this issue Aug 27, 2019 · 1 comment · Fixed by #404

Comments

@MarkusPiotrowski
Copy link

MarkusPiotrowski commented Aug 27, 2019

Updating pydocstyle from version 3.0.0 to version 4.0.0 or 4.0.1 throw numerous new D413 (and few D412) issues on code that passes with version 3.0.0.

Example: The following code:

"""Test module to demonstrate D413 problem."""


def example_1(one, two):
    """Demonstrate case.

    Arguments:
     - one      first argument
     - second   second argument

    This function shows if a D413 is thrown or not.
    In my view, this is not a D413.
    """
    pass


def example_2(one, two):
    """Demonstrate case.

    Attributes:
     - one      first attribute
     - second   second attribute

    This function shows if a D413 is thrown or not.
    In my view, this is not a D413.
    """
    pass


# Original PEP-257 example from https://www.python.org/dev/peps/pep-0257/:
def complex(real=0.0, imag=0.0):
    """Form a complex number.

    Keyword arguments:
    real -- the real part (default 0.0)
    imag -- the imaginary part (default 0.0)
    """
    if imag == 0.0 and real == 0.0:
        return complex_zero

throws 'only' one issue with pydocstyle ver. 3.0.0:

>pydocstyle --version
3.0.0

>pydocstyle D413_example.py
D413_example.py:18 in public function `example_2`:
        D413: Missing blank line after last section ('Attributes')

but 4 with ver. 4.0.1 (or 4.0.0), even with the original PEP-257 example (from https://www.python.org/dev/peps/pep-0257/):

>pydocstyle --version
4.0.1

>pydocstyle D413_example.py
D413_example.py:5 in public function `example_1`:
        D413: Missing blank line after last section ('Arguments')
D413_example.py:18 in public function `example_2`:
        D413: Missing blank line after last section ('Attributes')
D413_example.py:18 in public function `example_2`:
        D413: Missing blank line after last section ('Attributes')
D413_example.py:32 in public function `complex`:
        D413: Missing blank line after last section ('Keyword Arguments')

Actually, I think that no of these example docstrings should give an issue (at least in pep257 mode). The only way to get rid of this error is to put an empty line before the closing quotes, but this isn't a PEP 257 rule?

@samj1912
Copy link
Member

samj1912 commented Sep 19, 2019

From what I can see, the change that causes D413 to be throw is the addition of new section names in pydocstyle 4.0. Earlier Arguments or Keyword Arguments were not identified as sections, and as a result they never threw D413. Given the examples, it seems reasonable to exclude D413 from the pep257 convention entirely.

justinludwig added a commit to justinludwig/pydocstyle that referenced this issue Nov 26, 2019
As none of the examples in the
[Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
show a docstring with an extra blank line at the end (see the
[3.8.1 Docstrings](https://google.github.io/styleguide/pyguide.html#381-docstrings)
section in particular), error D413 should be excluded from the default
"google" convention.

See PyCQA#429 for a test case with examples from the Google Python Style
Guide; see also PyCQA#401 for D413 in relation to the "pep257" convention.
Nurdok pushed a commit that referenced this issue Nov 30, 2019
As none of the examples in the
[Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
show a docstring with an extra blank line at the end (see the
[3.8.1 Docstrings](https://google.github.io/styleguide/pyguide.html#381-docstrings)
section in particular), error D413 should be excluded from the default
"google" convention.

See #429 for a test case with examples from the Google Python Style
Guide; see also #401 for D413 in relation to the "pep257" convention.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants