-
-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check-docstring-first false positive on attribute docstrings #159
Comments
The goal of the hook was mostly to prevent imports-then-docstring (an especially common/easy mistake with future imports and docstrings), perhaps it can be adjusted to stop searching after it finds some non-import code (similar to the algorithm used in https://github.com/asottile/reorder_python_imports) |
Hey @asottile :) |
Doubt it, unless you can come up with a good heuristic for differentiating the mistake and the intentional "attribute docstring" |
@asottile Understood. Maybe close this issue then? |
It may be possible, I haven't invested any time into this particular issue as I don't use "attribute docstrings" - - normal comments work fine for me |
@asottile People use "attribute docstrings" becuase the sphinx autosummary documentation generator looks for docstrings following class-level and module-level variables and uses them to generate website documentation. This would actually be a useful feature for a lot of people. |
This issue is still open, if you can come up with a heuristic that properly identifies "attribute docstrings" vs the mistakes it currently catches then I'd happily entertain a tested patch. You'll notice I marked this as a bug and I haven't closed it, so please be careful of asserting that I'm being dismissive. I simply don't have any reason to work on this myself since I don't use that feature, but I'd be happy to guide you through implementing this :) I'm pretty sure you can also use this as a workaround (or at least I've seen comments like this in the past): attr = 1
#: comment about the attribute (I might be misremembering the exact format, it's been a while!) |
Sorry didn't mean to be rude; I corrected my tone! Obviously I'm super grateful for this project. I didn't know about |
I just ran into this. FWIW, just fyi, that there are use cases for which the |
false positives on attribute docstrings as per pre-commit/pre-commit-hooks#159 , particularly pre-commit/pre-commit-hooks#159 (comment)
Remove check-docstring-first pre-commit hook as it doesn't support using Sphinx attribute docstrings. Attribute docstrings, as defined in PEP-257 are strings immediately following top level module names. The check-docstring-first hook 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)" For details see related discussion on pre-commit issue: pre-commit/pre-commit-hooks#159 Signed-off-by: Stephan Linz <[email protected]>
Remove check-docstring-first pre-commit hook as it doesn't support using Sphinx attribute docstrings. Attribute docstrings, as defined in PEP-257 are strings immediately following top level module names. The check-docstring-first hook 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)" For details see related discussion on pre-commit issue: pre-commit/pre-commit-hooks#159 Signed-off-by: Stephan Linz <[email protected]>
Remove check-docstring-first pre-commit hook as it doesn't support using Sphinx attribute docstrings. Attribute docstrings, as defined in PEP-257 are strings immediately following top level module names. The check-docstring-first hook 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)" For details see related discussion on pre-commit issue: pre-commit/pre-commit-hooks#159 Signed-off-by: Stephan Linz <[email protected]>
Remove check-docstring-first pre-commit hook as it doesn't support using Sphinx attribute docstrings. Attribute docstrings, as defined in PEP-257 are strings immediately following top level module names. The check-docstring-first hook 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)" For details see related discussion on pre-commit issue: pre-commit/pre-commit-hooks#159 Signed-off-by: Stephan Linz <[email protected]>
check-docstring-first has to go unfortunately due to pre-commit/pre-commit-hooks#159.
Attribute docstrings, as defined in PEP-257 are strings immediately following top level module names. For example:
The check-docstring-first incorrectly identifies this attribute docstring as a module docstring, indicating either
Multiple module docstrings (first docstring on line N).
orModule 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.The text was updated successfully, but these errors were encountered: