From 4b70feb297b4aada56b838c1e71f40badccf9472 Mon Sep 17 00:00:00 2001 From: allanc65 <95424144+allanc65@users.noreply.github.com> Date: Fri, 3 Dec 2021 20:00:22 +0800 Subject: [PATCH] =?UTF-8?q?#5452:=20Fix=20false=20positive=20missing-doc-p?= =?UTF-8?q?aram=20from=20multi-line=20Google-st=E2=80=A6=20(#5459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #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> --- CONTRIBUTORS.txt | 3 +++ ChangeLog | 6 ++++++ pylint/extensions/_check_docs_utils.py | 13 +++---------- .../missing_param_doc_required_Google.py | 18 ++++++++++++++++++ .../missing_param_doc_required_Google.rc | 6 ++++++ 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py create mode 100644 tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 4b51cb2ffe..625b38e04f 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 a48b4ff395..2aa47648bc 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 18c2ec0b5a..5227e74aee 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -646,16 +646,9 @@ def match_param_docs(self): 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 0000000000..0e5bc8e4f3 --- /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 0000000000..dd77ffed41 --- /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