check-docstring-first false positive on attribute docstrings
See original GitHub issueAttribute docstrings, as defined in PEP-257 are strings immediately following top level module names. For example:
name = "my variable"
"""the name used by the module for x, y, and z"""
The check-docstring-first incorrectly identifies this attribute docstring as a module docstring, indicating either Multiple module docstrings (first docstring on line N).
or Module docstring appears after code (code seen on line N).
.
In light of this issue, I’m not sure the check-docstring-first
check has much value at all. At the very least, the check should not be failing when a docstring follows an assignment.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Google Style Docstring: support class attributes : PY-16760
Right now class attributed are not really supported in docstrings - completion, refactorings and types are not picked up from already specified attributes ......
Read more >Automate Your Python Code Documentation with Pre-commit ...
A hands-on guide to automating docstrings checks and auto-generating documentation ... The check-docstring-first pre-commit hook, which, ...
Read more >Writing better Python code, automatically - mje.nz
It produces more false positives than Flake8 but also catches more bugs, ... id: check-docstring-first - id: check-executables-have-shebangs ...
Read more >Boring Python: code quality - James Bennett
Pylint is generally slower and will have more false positives, ... You can also use the Sphinx autodoc plugin to pull in docstrings...
Read more >Documenting class attributes with type annotations
I do not think you can put an Attribute section inside of your docstring to get your desired results. I tried giving each...
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 this. FWIW,
#:
is not a part of PEP-257, and (more importantly for me,) comments starting with#:
are not picked up by vscode the way that attribute docstrings are.just fyi, that there are use cases for which the
#:
workaround doesn’t work.Doubt it, unless you can come up with a good heuristic for differentiating the mistake and the intentional “attribute docstring”