pydocstyle icon indicating copy to clipboard operation
pydocstyle copied to clipboard

numpy convention --> colon spacing should be verified for parameters and return sections

Open sappelhoff opened this issue 4 years ago • 1 comments

The following is an example of a numpy convention parameter documentation:

"""
Parameters
----------
a : int
    The value of a.
"""

The numpy docs say the following about that:

The colon must be preceded by a space, or omitted if the type is absent.

(source: https://numpydoc.readthedocs.io/en/latest/format.html#sections)

However, pydocstyle does not seem to verify this.

For example, take a file smalltest.py with the following contents:

"""Test some."""


def no(a):
    """Do it.

    Parameters
    ----------
    a: int
        Print a.
    """
    print(a)

running pydocstyle --convention=numpy smalltest.py does not show any errors, but it should.

version: 5.1.1 on ubuntu 18.04

sappelhoff avatar Jan 04 '21 10:01 sappelhoff

On the other hand, using numpydoc for validation reveals the issues appropriately:

python -m numpydoc smalltest.no --validate

smalltest.no:GL01:Docstring text (summary) should start in the line immediately after the opening quotes (not in the same line, or leaving a blank line in between)
smalltest.no:ES01:No extended summary found
smalltest.no:PR01:Parameters {'a'} not documented
smalltest.no:PR02:Unknown parameters {'a: int'}
smalltest.no:PR10:Parameter "a" requires a space before the colon separating the parameter name and type
smalltest.no:SA01:See Also section not found
smalltest.no:EX01:No examples section found

sappelhoff avatar Jan 19 '21 10:01 sappelhoff