summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallanc65 <95424144+allanc65@users.noreply.github.com>2021-12-03 20:00:22 +0800
committerGitHub <noreply@github.com>2021-12-03 13:00:22 +0100
commit4b70feb297b4aada56b838c1e71f40badccf9472 (patch)
tree3fd87ff4d713c5220ead58a790e749f1cb4ef01d
parent35813de38ed58855f1b89fb492dc141d24bf2661 (diff)
downloadpylint-git-4b70feb297b4aada56b838c1e71f40badccf9472.tar.gz
#5452: Fix false positive missing-doc-param from multi-line Google-st… (#5459)
* #5452: Fix false positive missing-doc-param from multi-line Google-style docstrings. Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-rw-r--r--CONTRIBUTORS.txt3
-rw-r--r--ChangeLog6
-rw-r--r--pylint/extensions/_check_docs_utils.py13
-rw-r--r--tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py18
-rw-r--r--tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc6
5 files changed, 36 insertions, 10 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 4b51cb2ff..625b38e04 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -582,3 +582,6 @@ contributors:
* Harshil (harshil21): contributor
* Felix von Drigalski (felixvd): contributor
+
+* Allan Chandler (allanc65): contributor
+ - Fixed issue 5452, false positive missing-param-doc for multi-line Google-style params
diff --git a/ChangeLog b/ChangeLog
index a48b4ff39..2aa47648b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,12 @@ Release date: TBA
Closes #5437
+* Fixed handling of Google-style parameter specifications where descriptions
+ are on the line following the parameter name. These were generating
+ false positives for ``missing-param-doc``.
+
+ Closes #5452
+
..
Insert your changelog randomly, it will reduce merge conflicts
(Ie. not necessarily at the end)
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index 18c2ec0b5..5227e74ae 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -646,16 +646,9 @@ class GoogleDocstring(Docstring):
if not match:
continue
- # check if parameter has description only
- re_only_desc = re.search(":\n", entry)
- if re_only_desc:
- param_name = match.group(1)
- param_desc = match.group(2)
- param_type = None
- else:
- param_name = match.group(1)
- param_type = match.group(2)
- param_desc = match.group(3)
+ param_name = match.group(1)
+ param_type = match.group(2)
+ param_desc = match.group(3)
if param_type:
params_with_type.add(param_name)
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
new file mode 100644
index 000000000..0e5bc8e4f
--- /dev/null
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
@@ -0,0 +1,18 @@
+"""Tests for missing-param-doc and missing-type-doc for Google style docstrings
+with accept-no-param-doc = no
+
+Styleguide:
+https://google.github.io/styleguide/pyguide.html#doc-function-args
+"""
+# pylint: disable=invalid-name
+
+
+def test_multi_line_parameters(param: int) -> None:
+ """Checks that multi line parameters lists are checked correctly
+ See https://github.com/PyCQA/pylint/issues/5452
+
+ Args:
+ param:
+ a description
+ """
+ print(param)
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
new file mode 100644
index 000000000..dd77ffed4
--- /dev/null
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
@@ -0,0 +1,6 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-param-doc=no
+docstring-min-length: -1