pylint
pylint copied to clipboard
accept-no-raise-doc is not checked for docstrings with at least one matching section
Bug description
The docstyle extension sometimes ignores the accept-no-raise-doc option because the _add_raise_message
method is invoked directly instead of _handle_no_raise_doc
in visit_raise
.
"""Minimal example where a W9006 message is displayed even if the
accept-no-raise-doc option is set to True.
Requires at least one matching section (`Docstring.matching_sections`)."""
def w9006issue(dummy: int):
"""Sample function.
:param dummy: Unused
"""
raise AssertionError()
Configuration
[MAIN]
load-plugins=pylint.extensions.docparams
[pylint.extensions.docstyle]
accept-no-raise-doc=yes
Command used
pylint w9006_issue.py
Pylint output
************* Module w9006_issue
w9006_issue.py:6:0: W9006: "AssertionError" not documented as being raised (missing-raises-doc)
------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)
Expected behavior
The expected behavior is to have pylint display no message.
Pylint version
pylint 2.14.5
astroid 2.11.7
Python 3.8.5 (default, Sep 7 2020, 16:44:59)
OS / Environment
Debian 9.13 (stretch)
Additional dependencies
No response
A suggested fix is to call _handle_no_raise_doc
.
diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py
index c3253c89e..a77ac916d 100644
--- a/pylint/extensions/docparams.py
+++ b/pylint/extensions/docparams.py
@@ -313,7 +313,7 @@ class DocstringParameterChecker(BaseChecker):
else:
missing_excs.add(expected.name)
- self._add_raise_message(missing_excs, func_node)
+ self._handle_no_raise_doc(missing_excs, func_node)
def visit_return(self, node: nodes.Return) -> None:
if not utils.returns_something(node):
Very nice bug report thank you. I credited you in the fix as you did almost everything, please feel free to review in #7212.
I tried to fix this issue in a new PR #7581.
There is still a breaking change, because one test was assuming that the default value for accept-no-raise-doc
was False, despite it being True.
I suspect other projects might be affected by this change in the same way.