pydocstyle
pydocstyle copied to clipboard
D414 false positive on function with Numpy convention
Hi I have this function and pydocstyle recognises argument attributes in docstring as a section but Attributes section belongs to a class
This is related to #318
numpy style reference: https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
def parse_attributes(attributes):
"""
Parse resource attributes.
Parameters
----------
attributes
Resource attributes.
"""
print(attributes)
Same with parameters which results in D405,406,407,410,411,414, all of them twice except 406:
"""Demo module for parameters bug."""
def foo(parameters):
"""Do something.
Parameters
----------
parameters:
a list of parameters
"""
Linting above file gives following output (with pydocstyle 4.0.1):
foo.py:4 in public function `foo`:
D410: Missing blank line after section ('Parameters')
foo.py:4 in public function `foo`:
D414: Section has no content ('Parameters')
foo.py:4 in public function `foo`:
D405: Section name should be properly capitalized ('Parameters', not 'parameters')
foo.py:4 in public function `foo`:
D411: Missing blank line before section ('Parameters')
foo.py:4 in public function `foo`:
D407: Missing dashed underline after section ('Parameters')
foo.py:4 in public function `foo`:
D406: Section name should end with a newline ('Parameters', not 'parameters:')
foo.py:4 in public function `foo`:
D410: Missing blank line after section ('Parameters')
foo.py:4 in public function `foo`:
D414: Section has no content ('Parameters')
foo.py:4 in public function `foo`:
D405: Section name should be properly capitalized ('Parameters', not 'parameters')
foo.py:4 in public function `foo`:
D411: Missing blank line before section ('Parameters')
foo.py:4 in public function `foo`:
D407: Missing dashed underline after section ('Parameters')```
Would it be a solution to introduce a state machine which marks already passed sections as such so that they will not be mixed up with any following attribute/parameter definitions?
In the case above, the parser could mark that it has already seen a section `Parameters` and then not check for a `Parameters` section again. In case someone really has two parameter sections, this will of course pass unnoticed, but all those false positives right now are IMHO the larger annoyance.
Oddly enough, if you omit the . at the end of the parameter description for params like attributes: these errors go away for some reason.