Variable docstring triggers WPS428 and WPS322
See original GitHub issueBug report
What’s wrong
Defining a variable docstring triggers both WPS428 (found statement that has no effect) and, if it’s a single line, it will also trigger WPS322 (found incorrect multi-line string).
An example:
my_var = 1
"""This is my variable."""
How is that should be
These docstrings are not normal python syntax, but are recognized by sphinx and thus are fairly common. Therfore, these should be treated as normal docstrings and not raise errors.
System information
flake8 information
Contents of flake8 --bug-report
:
$ flake8 --bug-report
{
"dependencies": [],
"platform": {
"python_implementation": "CPython",
"python_version": "3.8.2",
"system": "Linux"
},
"plugins": [
{
"is_local": false,
"plugin": "flake8-bandit",
"version": "2.1.2"
},
{
"is_local": false,
"plugin": "flake8-broken-line",
"version": "0.2.1"
},
{
"is_local": false,
"plugin": "flake8-bugbear",
"version": "19.8.0"
},
{
"is_local": false,
"plugin": "flake8-comprehensions",
"version": "3.2.3"
},
{
"is_local": false,
"plugin": "flake8-darglint",
"version": "1.5.2"
},
{
"is_local": false,
"plugin": "flake8-debugger",
"version": "3.2.1"
},
{
"is_local": false,
"plugin": "flake8-docstrings",
"version": "1.5.0, pydocstyle: 5.0.2"
},
{
"is_local": false,
"plugin": "flake8-eradicate",
"version": "0.3.0"
},
{
"is_local": false,
"plugin": "flake8-string-format",
"version": "0.2.3"
},
{
"is_local": false,
"plugin": "flake8_commas",
"version": "2.0.0"
},
{
"is_local": false,
"plugin": "flake8_isort",
"version": "3.0.1"
},
{
"is_local": false,
"plugin": "flake8_quotes",
"version": "2.1.2"
},
{
"is_local": false,
"plugin": "mccabe",
"version": "0.6.1"
},
{
"is_local": false,
"plugin": "naming",
"version": "0.9.1"
},
{
"is_local": false,
"plugin": "pycodestyle",
"version": "2.6.0"
},
{
"is_local": false,
"plugin": "pyflakes",
"version": "2.2.0"
},
{
"is_local": false,
"plugin": "rst-docstrings",
"version": "0.0.12"
},
{
"is_local": false,
"plugin": "use-fstring-format",
"version": "1.0"
},
{
"is_local": false,
"plugin": "use-fstring-percent",
"version": "1.0"
},
{
"is_local": false,
"plugin": "use-fstring-prefix",
"version": "1.0"
},
{
"is_local": false,
"plugin": "wemake_python_styleguide",
"version": "0.14.1"
}
],
"version": "3.8.3"
pip information
Contents of pip freeze
:
alembic==1.4.2
appdirs==1.4.4
astor==0.8.1
attrs==20.1.0
bandit==1.6.2
black==19.10b0
cfgv==3.2.0
click==7.1.2
colorama==0.4.3
commitizen==2.1.0
coverage==5.2.1
darglint==1.5.2
decli==0.5.2
distlib==0.3.1
docutils==0.16
eradicate==1.0
filelock==3.0.12
flake8==3.8.3
flake8-bandit==2.1.2
flake8-broken-line==0.2.1
flake8-bugbear==19.8.0
flake8-commas==2.0.0
flake8-comprehensions==3.2.3
flake8-debugger==3.2.1
flake8-docstrings==1.5.0
flake8-eradicate==0.3.0
flake8-isort==3.0.1
flake8-polyfill==1.0.2
flake8-quotes==2.1.2
flake8-rst-docstrings==0.0.12
flake8-string-format==0.2.3
flake8-use-fstring==1.1
gitdb==4.0.5
GitPython==3.1.7
hypothesis==5.24.4
identify==1.4.28
iniconfig==1.0.1
isort==4.3.21
Jinja2==2.11.2
Mako==1.1.3
MarkupSafe==1.1.1
mccabe==0.6.1
mediafile==0.6.0
-e git+git@github.com:jtpavlock/moe.git@d6fce3deaa74d6f5ab6c9dc20ec00eae0049cae8#egg=moe
more-itertools==8.4.0
mutagen==1.45.1
mypy==0.782
mypy-extensions==0.4.3
nodeenv==1.4.0
packaging==20.4
pathspec==0.8.0
pbr==5.4.5
pep8-naming==0.9.1
pluggy==0.13.1
pre-commit==2.6.0
prompt-toolkit==3.0.6
py==1.9.0
pycodestyle==2.6.0
pydocstyle==5.0.2
pyflakes==2.2.0
Pygments==2.6.1
pyparsing==2.4.7
pytest==6.0.1
pytest-cov==2.10.1
python-dateutil==2.8.1
python-editor==1.0.4
PyYAML==5.3.1
questionary==1.5.2
regex==2020.7.14
restructuredtext-lint==1.3.1
six==1.15.0
smmap==3.0.4
snowballstemmer==2.0.0
sortedcontainers==2.2.2
SQLAlchemy==1.3.19
sqlalchemy-stubs==0.3
stevedore==3.2.0
termcolor==1.1.0
testfixtures==6.14.1
toml==0.10.1
tomlkit==0.5.11
typed-ast==1.4.1
typing-extensions==3.7.4.2
virtualenv==20.0.31
wcwidth==0.2.5
wemake-python-styleguide==0.14.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Variable docstring triggers WPS428 and WPS322 #1574
Defining a variable docstring triggers both WPS428 (found statement that has no effect) and, if it's a single line, it will also trigger...
Read more >Python Docstrings - Epydoc
Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods.
Read more >How to Document Your Code - pydoctor documentation
class C: cvar = None """This docstring describes a class variable. ... document the potential warning a function (or method) can trigger.
Read more >PEP 8 – Style Guide for Python Code
This document and PEP 257 (Docstring Conventions) were adapted from Guido's original Python Style Guide essay, with some additions from ...
Read more >How to document a module constant in Python? - Stack Overflow
Unfortunately, variables (and constants) do not have docstrings. After all, the variable is just a name for an integer, and you wouldn't want...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just ran into the same problem when I tried to document a constant. Docstrings for variables are part of the docstring PEP257 (and PEP258 I guess).
Besides WPS428 and WPS322 there is also WPS462 being reported on the preceding line (the constant declaration). It is of course possible to ignore these violations but then I loose these violations for all other cases.
Same issue.
@sobolevn
#:
isn’t PEP standardized and vscode doesn’t support such documentation. It will be great if you allow configuring the violation.