|Missing docstring in public module
|Missing docstring in public class
|Missing docstring in public method
|Missing docstring in public function
|Missing docstring in public package
|Missing docstring in magic method
|Missing docstring in public nested class
|Missing docstring in __init__
|One-line docstring should fit on one line with quotes
|No blank lines allowed before function docstring
|No blank lines allowed after function docstring
|1 blank line required before class docstring
|1 blank line required after class docstring
|1 blank line required between summary line and description
|Docstring should be indented with spaces, not tabs
|Docstring is under-indented
|Docstring is over-indented
|Multi-line docstring closing quotes should be on a separate line
|No whitespaces allowed surrounding docstring text
|No blank lines allowed before class docstring
|Multi-line docstring summary should start at the first line
|Multi-line docstring summary should start at the second line
|Section is over-indented
|Section underline is over-indented
|Use “”“triple double quotes”“”
|Use r”“” if any backslashes in a docstring
|Use u”“” for Unicode docstrings
|Docstring Content Issues
|First line should end with a period
|First line should be in imperative mood
|First line should be in imperative mood; try rephrasing
|First line should not be the function’s “signature”
|First word of the first line should be properly capitalized
|First word of the docstring should not be This
|Section name should be properly capitalized
|Section name should end with a newline
|Missing dashed underline after section
|Section underline should be in the line following the section’s name
|Section underline should match the length of its name
|Missing blank line after section
|Missing blank line before section
|No blank lines allowed between a section header and its content
|Missing blank line after last section
|Section has no content
|First line should end with a period, question mark, or exclamation point
|Section name should end with a semicolon
|Missing arguments in the function docstring
Not all error codes are checked for by default. There are two conventions that may be used by pydocstyle: pep257 and numpy.
The pep257 convention, which is enabled by default in pydocstyle, checks for all of the above errors except for D203, D212, D213, D214, D215, D404, D405, D406, D407, D408, D409, D410, and D411 (as specified in PEP257).
The numpy convention checks for all of the above errors except for D107, D203, D212, D213, D402, and D413.
These conventions may be specified using –convention=<name> when running pydocstyle from the command line or by specifying the convention in a configuration file. See the Usage section for more details.
The D1xx group of errors deals with missing docstring in public constructs: modules, classes, methods, etc. It is important to note how publicity is determined and what its effects are.
How publicity is determined¶
Publicity for all constructs is determined as follows: a construct is considered public if -
- Its immediate parent is public and
- Its name does not contain a single leading underscore.
A construct’s immediate parent is the construct that contains it. For example, a method’s parent is a class object. A class’ parent is usually a module, but might also be a function, method, etc. A module can either have no parent, or it can have a parent that is a package.
In order for a construct to be considered public, its immediate parent must
also be public. Since this definition is recursive, it means that all of its
parents need to be public. The corollary is that if a construct is considered
private, then all of its descendants are also considered private. For example,
a class called
_Foo is considered private. A method
also considered private since its parent is a private class, even though its
name does not begin with a single underscore.
Modules are parsed to look if
__all__ is defined. If so, only those top
level constructs are considered public. The parser looks for
defined as a literal list or tuple. As the parser doesn’t execute the module,
any mutation of
__all__ will not be considered.
How publicity affects error reports¶
The immediate effect of a construct being determined as private is that no D1xx errors will be reported for it (or its children, as the previous section explains). A private method, for instance, will not generate a D102 error, even if it has no docstring.
However, it is important to note that while docstring are optional for private construct, they are still required to adhere to your style guide. So if a private module _foo.py does not have a docstring, it will not generate a D100 error, but if it does have a docstring, that docstring might generate other errors.