question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

check-docstring-first false positive on attribute docstrings

See original GitHub issue

Attribute 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanrheecommented, Jan 18, 2022

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.

1reaction
asottilecommented, Jul 10, 2019

Doubt it, unless you can come up with a good heuristic for differentiating the mistake and the intentional “attribute docstring”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found