summaryrefslogtreecommitdiff
path: root/pylint/extensions
diff options
context:
space:
mode:
authorBrice Chardin <brice.chardin@gmail.com>2022-10-28 08:49:29 +0200
committerGitHub <noreply@github.com>2022-10-28 08:49:29 +0200
commit7646a1a7d4ac54d36cb4de24a2e0d30b264a342f (patch)
treef44de7f7dc02c0c376fbed1f8be6dbaddb59e68a /pylint/extensions
parentd295b71bfe25103620c99796aed077152e2e1966 (diff)
downloadpylint-git-7646a1a7d4ac54d36cb4de24a2e0d30b264a342f.tar.gz
Take 'accept-no-raise-doc' option into account (#7581)
Check the accept-no-raise-doc option when the docstring has matching sections (Fixes #7208) Defaut value for accept-no-raise-doc is True, but tests in `missing_doc_required_Sphinx.py` assume that this option is set to False. Co-authored-by: Brice Chardin <brice.chardin@ensma.fr>
Diffstat (limited to 'pylint/extensions')
-rw-r--r--pylint/extensions/docparams.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py
index 19d9cf890..62ada6824 100644
--- a/pylint/extensions/docparams.py
+++ b/pylint/extensions/docparams.py
@@ -298,10 +298,14 @@ class DocstringParameterChecker(BaseChecker):
doc = utils.docstringify(
func_node.doc_node, self.linter.config.default_docstring_type
)
+
+ if self.linter.config.accept_no_raise_doc and not doc.exceptions():
+ return
+
if not doc.matching_sections():
if doc.doc:
missing = {exc.name for exc in expected_excs}
- self._handle_no_raise_doc(missing, func_node)
+ self._add_raise_message(missing, func_node)
return
found_excs_full_names = doc.exceptions()
@@ -652,12 +656,6 @@ class DocstringParameterChecker(BaseChecker):
confidence=HIGH,
)
- def _handle_no_raise_doc(self, excs: set[str], node: nodes.FunctionDef) -> None:
- if self.linter.config.accept_no_raise_doc:
- return
-
- self._add_raise_message(excs, node)
-
def _add_raise_message(
self, missing_exceptions: set[str], node: nodes.FunctionDef
) -> None: