'\" t .\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "PYDOCSTYLE" "1" "2024-01-14" "0.0.0" "pydocstyle" .SH NAME pydocstyle \- pydocstyle Documentation .sp \fBpydocstyle\fP is a static analysis tool for checking compliance with Python docstring conventions. .sp \fBpydocstyle\fP supports most of \fI\%PEP 257\fP out of the box, but it should not be considered a reference implementation. .sp \fBpydocstyle\fP supports Python 3.7 through 3.11. .sp Although pydocstyle is tries to be compatible with Python 3.6, it is not tested. .INDENT 0.0 .IP 1. 3 Install .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX pip install pydocstyle .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .IP 2. 3 Run .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX $ pydocstyle test.py test.py:18 in private nested class \(gameta\(ga: D101: Docstring missing test.py:27 in public function \(gaget_user\(ga: D300: Use \(dq\(dq\(dqtriple double quotes\(dq\(dq\(dq (found \(aq\(aq\(aq\-quotes) test:75 in public function \(gainit_database\(ga: D201: No blank lines allowed before function docstring (found 1) \&... .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .IP 3. 3 Fix your code :) .UNINDENT .sp Contents: .SH USAGE .SS Installation .sp Use \fI\%pip\fP or easy_install: .INDENT 0.0 .INDENT 3.5 .sp .EX pip install pydocstyle .EE .UNINDENT .UNINDENT .sp Alternatively, you can use \fBpydocstyle.py\fP source file directly \- it is self\-contained. .SS Command Line Interface .SS Usage .INDENT 0.0 .INDENT 3.5 .sp .EX Usage: pydocstyle [options] [...] Options: \-\-version show program\(aqs version number and exit \-h, \-\-help show this help message and exit \-e, \-\-explain show explanation of each error \-s, \-\-source show source for each error \-d, \-\-debug print debug information \-v, \-\-verbose print status information \-\-count print total number of errors to stdout \-\-config= use given config file and disable config discovery \-\-match= check only files that exactly match regular expression; default is \-\-match=\(aq(?!test_).*\e.py\(aq which matches files that don\(aqt start with \(aqtest_\(aq but end with \(aq.py\(aq \-\-match\-dir= search only dirs that exactly match regular expression; default is \-\-match\-dir=\(aq[^\e.].*\(aq, which matches all dirs that don\(aqt start with a dot \-\-ignore\-decorators= ignore any functions or methods that are decorated by a function with a name fitting the regular expression; default is \-\-ignore\-decorators=\(aq\(aq which does not ignore any decorated functions. Note: When using \-\-match, \-\-match\-dir or \-\-ignore\-decorators consider whether you should use a single quote (\(aq) or a double quote (\(dq), depending on your OS, Shell, etc. Error Check Options: Only one of \-\-select, \-\-ignore or \-\-convention can be specified. If none is specified, defaults to \(ga\-\-convention=pep257\(ga. These three options select the \(dqbasic list\(dq of error codes to check. If you wish to change that list (for example, if you selected a known convention but wish to ignore a specific error from it or add a new one) you can use \(ga\-\-add\-[ignore/select]\(ga in order to do so. \-\-select= choose the basic list of checked errors by specifying which errors to check for (with a list of comma\- separated error codes or prefixes). for example: \-\-select=D101,D2 \-\-ignore= choose the basic list of checked errors by specifying which errors to ignore out of all of the available error codes (with a list of comma\-separated error codes or prefixes). for example: \-\-ignore=D101,D2 \-\-convention= choose the basic list of checked errors by specifying an existing convention. Possible conventions: pep257, numpy, google. \-\-add\-select= add extra error codes to check to the basic list of errors previously set by \-\-select, \-\-ignore or \-\-convention. \-\-add\-ignore= ignore extra error codes by removing them from the basic list previously set by \-\-select, \-\-ignore or \-\-convention. .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When using any of the \fB\-\-select\fP, \fB\-\-ignore\fP, \fB\-\-add\-select\fP, or \fB\-\-add\-ignore\fP command line flags, it is possible to pass a prefix for an error code. It will be expanded so that any code beginning with that prefix will match. For example, running the command \fBpydocstyle \-\-ignore=D4\fP will ignore all docstring content issues as their error codes beginning with \(dqD4\(dq (i.e. D400, D401, D402, D403, and D404). .UNINDENT .UNINDENT .SS Return Code .TS center; |l|l|. _ T{ 0 T} T{ Success \- no violations T} _ T{ 1 T} T{ Some code violations were found T} _ T{ 2 T} T{ Illegal usage \- see error message T} _ .TE .SS Configuration Files .sp \fBpydocstyle\fP supports \fIini\fP\-like and \fItoml\fP configuration files. In order for \fBpydocstyle\fP to use a configuration file automatically, it must be named one of the following options. .INDENT 0.0 .IP \(bu 2 \fBsetup.cfg\fP .IP \(bu 2 \fBtox.ini\fP .IP \(bu 2 \fB\&.pydocstyle\fP .IP \(bu 2 \fB\&.pydocstyle.ini\fP .IP \(bu 2 \fB\&.pydocstylerc\fP .IP \(bu 2 \fB\&.pydocstylerc.ini\fP .IP \(bu 2 \fBpyproject.toml\fP .UNINDENT .sp When searching for a configuration file, \fBpydocstyle\fP looks for one of the file specified above \fIin that exact order\fP\&. \fIini\fP\-like configuration files must have a \fB[pydocstyle]\fP section while \fItoml\fP configuration files must have a \fB[tool.pydocstyle]\fP section. If a configuration file was not found, \fBpydocstyle\fP keeps looking for one up the directory tree until one is found or uses the default configuration. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fItoml\fP configuration file support is only enabled if the \fBtoml\fP python package is installed. You can ensure that this is the case by installing the \fBpydocstyle[toml]\fP optional dependency. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For backwards compatibility purposes, \fBpydocstyle\fP supports configuration files named \fB\&.pep257\fP, as well as section header \fB[pep257]\fP\&. However, these are considered deprecated and support will be removed in the next major version. .UNINDENT .UNINDENT .SS Available Options .sp Not all configuration options are available in the configuration files. Available options are: .INDENT 0.0 .IP \(bu 2 \fBconvention\fP .IP \(bu 2 \fBselect\fP .IP \(bu 2 \fBignore\fP .IP \(bu 2 \fBadd_select\fP .IP \(bu 2 \fBadd_ignore\fP .IP \(bu 2 \fBmatch\fP .IP \(bu 2 \fBmatch_dir\fP .IP \(bu 2 \fBignore_decorators\fP .IP \(bu 2 \fBproperty_decorators\fP .IP \(bu 2 \fBignore_self_only_init\fP .UNINDENT .sp See the \fI\%Usage\fP section for more information. .SS Inheritance .sp By default, when finding a configuration file, \fBpydocstyle\fP tries to inherit the parent directory\(aqs configuration and merge them to the local ones. .sp The merge process is as follows: .INDENT 0.0 .IP \(bu 2 If one of \fBselect\fP, \fBignore\fP or \fBconvention\fP was specified in the child configuration \- Ignores the parent configuration and set the new error codes to check. Otherwise, simply copies the parent checked error codes. .IP \(bu 2 If \fBadd\-ignore\fP or \fBadd\-select\fP were specified, adds or removes the specified error codes from the checked error codes list. .IP \(bu 2 If \fBmatch\fP or \fBmatch\-dir\fP were specified \- use them. Otherwise, use the parent\(aqs. .UNINDENT .sp In order to disable this (useful for configuration files located in your repo\(aqs root), simply add \fBinherit=false\fP to your configuration file. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If any of \fBselect\fP, \fBignore\fP or \fBconvention\fP were specified in the CLI, the configuration files will take no part in choosing which error codes will be checked. \fBmatch\fP and \fBmatch\-dir\fP will still take effect. .UNINDENT .UNINDENT .SS Example .INDENT 0.0 .INDENT 3.5 .sp .EX [pydocstyle] inherit = false ignore = D100,D203,D405 match = .*\e.py .EE .UNINDENT .UNINDENT .SS In\-file configuration .sp \fBpydocstyle\fP supports inline commenting to skip specific checks on specific functions or methods. The supported comments that can be added are: .INDENT 0.0 .IP 1. 3 \fB\(dq# noqa\(dq\fP skips all checks. .IP 2. 3 \fB\(dq# noqa: D102,D203\(dq\fP can be used to skip specific checks. Note that this is compatible with skips from \fI\%flake8\fP, e.g. \fB# noqa: D102,E501,D203\fP\&. .UNINDENT .sp For example, this will skip the check for a period at the end of a function docstring: .INDENT 0.0 .INDENT 3.5 .sp .EX >>> def bad_function(): # noqa: D400 \&... \(dq\(dq\(dqOmit a period in the docstring as an exception\(dq\(dq\(dq \&... pass .EE .UNINDENT .UNINDENT .SS Usage with the \fI\%pre\-commit\fP git hooks framework .sp \fBpydocstyle\fP can be included as a hook for \fI\%pre\-commit\fP\&. The easiest way to get started is to add this configuration to your \fB\&.pre\-commit\-config.yaml\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX \- repo: \fI\%https://github.com/pycqa/pydocstyle\fP rev: 0.0.0 # pick a git hash / tag to point to hooks: \- id: pydocstyle .EE .UNINDENT .UNINDENT .sp See the \fI\%pre\-commit docs\fP for how to customize this configuration. .sp Checked\-in python files will be passed as positional arguments so no need to use \fB\-\-match=*.py\fP\&. You can also use command line arguments instead of configuration files to achieve the same effect with less files. .INDENT 0.0 .INDENT 3.5 .sp .EX \- id: pydocstyle args: \- \-\-ignore=D100,D203,D405 # or multiline \- |\- \-\-select= D101, D2 .EE .UNINDENT .UNINDENT .SH ERROR CODES .SS Grouping .TS center; |l|l|. _ T{ \fBMissing Docstrings\fP T} _ T{ D100 T} T{ Missing docstring in public module T} _ T{ D101 T} T{ Missing docstring in public class T} _ T{ D102 T} T{ Missing docstring in public method T} _ T{ D103 T} T{ Missing docstring in public function T} _ T{ D104 T} T{ Missing docstring in public package T} _ T{ D105 T} T{ Missing docstring in magic method T} _ T{ D106 T} T{ Missing docstring in public nested class T} _ T{ D107 T} T{ Missing docstring in __init__ T} _ T{ \fBWhitespace Issues\fP T} _ T{ D200 T} T{ One\-line docstring should fit on one line with quotes T} _ T{ D201 T} T{ No blank lines allowed before function docstring T} _ T{ D202 T} T{ No blank lines allowed after function docstring T} _ T{ D203 T} T{ 1 blank line required before class docstring T} _ T{ D204 T} T{ 1 blank line required after class docstring T} _ T{ D205 T} T{ 1 blank line required between summary line and description T} _ T{ D206 T} T{ Docstring should be indented with spaces, not tabs T} _ T{ D207 T} T{ Docstring is under\-indented T} _ T{ D208 T} T{ Docstring is over\-indented T} _ T{ D209 T} T{ Multi\-line docstring closing quotes should be on a separate line T} _ T{ D210 T} T{ No whitespaces allowed surrounding docstring text T} _ T{ D211 T} T{ No blank lines allowed before class docstring T} _ T{ D212 T} T{ Multi\-line docstring summary should start at the first line T} _ T{ D213 T} T{ Multi\-line docstring summary should start at the second line T} _ T{ D214 T} T{ Section is over\-indented T} _ T{ D215 T} T{ Section underline is over\-indented T} _ T{ \fBQuotes Issues\fP T} _ T{ D300 T} T{ Use \(dq\(dq\(dqtriple double quotes\(dq\(dq\(dq T} _ T{ D301 T} T{ Use r\(dq\(dq\(dq if any backslashes in a docstring T} _ T{ D302 T} T{ Deprecated: Use u\(dq\(dq\(dq for Unicode docstrings T} _ T{ \fBDocstring Content Issues\fP T} _ T{ D400 T} T{ First line should end with a period T} _ T{ D401 T} T{ First line should be in imperative mood T} _ T{ D401 T} T{ First line should be in imperative mood; try rephrasing T} _ T{ D402 T} T{ First line should not be the function\(aqs \(dqsignature\(dq T} _ T{ D403 T} T{ First word of the first line should be properly capitalized T} _ T{ D404 T} T{ First word of the docstring should not be \fIThis\fP T} _ T{ D405 T} T{ Section name should be properly capitalized T} _ T{ D406 T} T{ Section name should end with a newline T} _ T{ D407 T} T{ Missing dashed underline after section T} _ T{ D408 T} T{ Section underline should be in the line following the section\(aqs name T} _ T{ D409 T} T{ Section underline should match the length of its name T} _ T{ D410 T} T{ Missing blank line after section T} _ T{ D411 T} T{ Missing blank line before section T} _ T{ D412 T} T{ No blank lines allowed between a section header and its content T} _ T{ D413 T} T{ Missing blank line after last section T} _ T{ D414 T} T{ Section has no content T} _ T{ D415 T} T{ First line should end with a period, question mark, or exclamation point T} _ T{ D416 T} T{ Section name should end with a colon T} _ T{ D417 T} T{ Missing argument descriptions in the docstring T} _ T{ D418 T} T{ Function/ Method decorated with @overload shouldn\(aqt contain a docstring T} _ T{ D419 T} T{ Docstring is empty T} _ .TE .SS Default conventions .sp Not all error codes are checked for by default. There are three conventions that may be used by pydocstyle: \fBpep257\fP, \fBnumpy\fP and \fBgoogle\fP\&. .sp The \fBpep257\fP convention (specified in \fI\%PEP257\fP), 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, D411, D413, D415, D416 and D417. .sp The \fBnumpy\fP convention added in v2.0.0 supports the \fI\%numpydoc docstring\fP standard. This checks all of the errors except for D107, D203, D212, D213, D402, D413, D415, D416, and D417. .sp The \fBgoogle\fP convention added in v4.0.0 supports the \fI\%Google Python Style Guide\fP\&. This checks for all the errors except D203, D204, D213, D215, D400, D401, D404, D406, D407, D408, D409 and D413. .sp These conventions may be specified using \fB\-\-convention=\fP when running pydocstyle from the command line or by specifying the convention in a configuration file. See the \fI\%Usage\fP section for more details. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It makes no sense to check the same docstring for both \fBnumpy\fP and \fBgoogle\fP conventions. Therefore, if we successfully detect that a docstring is in the \fBnumpy\fP style, we don\(aqt check it for \fBgoogle\fP\&. .sp The reason \fBnumpy\fP style takes precedence over \fBgoogle\fP is that the heuristics of detecting it are better, and we don\(aqt want to enforce users to provide external hints to \fIpydocstyle\fP in order to let it know which style docstrings are written in. .UNINDENT .UNINDENT .SS Publicity .sp 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. .SS How publicity is determined .sp Publicity for all constructs is determined as follows: a construct is considered \fIpublic\fP if \- .INDENT 0.0 .IP 1. 3 Its immediate parent is public \fIand\fP .IP 2. 3 Its name does \fInot\fP start with a single or double underscore. .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP a. 3 Note, names that start and end with a double underscore are \fIpublic\fP (e.g. \fB__init__.py\fP). .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp A construct\(aqs immediate parent is the construct that contains it. For example, a method\(aqs parent is a class object. A class\(aq 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. .sp In order for a construct to be considered public, its immediate parent must also be public. Since this definition is recursive, it means that \fIall\fP 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 \fB_Foo\fP is considered private. A method \fBbar\fP in \fB_Foo\fP is also considered private since its parent is a private class, even though its name does not begin with a single underscore. .sp Note, a module\(aqs parent is recursively checked upward until we reach a directory in \fBsys.path\fP to avoid considering the complete filepath of a module. For example, consider the module \fB/_foo/bar/baz.py\fP\&. If \fBPYTHONPATH\fP is set to \fB/\fP, then \fBbaz.py\fP is \fIprivate\fP\&. If \fBPYTHONPATH\fP is set to \fB/_foo/\fP, then \fBbaz.py\fP is \fIpublic\fP\&. .sp Modules are parsed to look if \fB__all__\fP is defined. If so, only those top level constructs are considered public. The parser looks for \fB__all__\fP defined as a literal list or tuple. As the parser doesn\(aqt execute the module, any mutation of \fB__all__\fP will not be considered. .SS How publicity affects error reports .sp 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. .sp 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 \fI_foo.py\fP does not have a docstring, it will not generate a D100 error, but if it \fIdoes\fP have a docstring, that docstring might generate other errors. .sp pydocstyle is a rename and continuation of pep257, a project created by Vladimir Keleshev. .sp Maintained by Amir Rachum and Sambhav Kothari. .SH AUTHOR Amir Rachum .SH COPYRIGHT 2024, Amir Rachum, Sambhav Kothari .\" Generated by docutils manpage writer. .