.\" Man page generated from reStructuredText. . .TH "PYDOCSTYLE" "1" "2017-06-12" "1.0.0" "pydocstyle" .SH NAME pydocstyle \- pydocstyle Documentation . .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 .. .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 2.7, 3.3, 3.4, 3.5 and pypy. .INDENT 0.0 .IP 1. 3 Install .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install pydocstyle .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .IP 2. 3 Run .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ 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 """triple double quotes""" (found \(aq\(aq\(aq\-quotes) test:75 in public function \(gainit_database\(ga: D201: No blank lines allowed before function docstring (found 1) \&... .ft P .fi .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 .nf .ft C pip install pydocstyle .ft P .fi .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 .nf .ft C 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 \-\-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 (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 \-\-add\-select= amend the list of errors to check for by specifying more error codes to check. \-\-add\-ignore= amend the list of errors to check for by specifying more error codes to ignore. \-\-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. .ft P .fi .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 begining with that prefix will match. For example, running the command \fBpydocstyle \-\-ignore=D4\fP will ignore all docstring content issues as their error codes begining with "D4" (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 configuration files. In order for \fBpydocstyle\fP to use it, it must be named one of the following options, and have a \fB[pydocstyle]\fP section. .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 .UNINDENT .sp When searching for a configuration file, \fBpydocstyle\fP looks for one of the file specified above \fIin that exact order\fP\&. If a configuration file was not found, it 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 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 .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 .nf .ft C [pydocstyle] inherit = false ignore = D100,D203,D405 match = *.py .ft P .fi .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"# noqa"\fP skips all checks. .IP 2. 3 \fB"# noqa: D102,D203"\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 .nf .ft C >>> def bad_function(): # noqa: D400 \&... """Omit a period in the docstring as an exception""" \&... pass .ft P .fi .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{ \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 """triple double quotes""" T} _ T{ D301 T} T{ Use r""" if any backslashes in a docstring T} _ T{ D302 T} T{ Use u""" 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 "signature" 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} _ .TE .SS Default Checks .sp Not all error codes are checked for by default. The default behavior is to check only error codes that are part of the \fI\%PEP257\fP official convention. .sp All of the above error codes are checked for by default except for D203, D212, D213 and D404. .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 not contain a single leading underscore. .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 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. .SH AUTHOR Amir Rachum .SH COPYRIGHT 2017, Amir Rachum .\" Generated by docutils manpage writer. .