Skip to content

Commit

Permalink
#5452: Fix false positive missing-doc-param from multi-line Google-st… (
Browse files Browse the repository at this point in the history
#5459)

* #5452: Fix false positive missing-doc-param from multi-line Google-style docstrings.

Co-authored-by: Daniël van Noord <[email protected]>
  • Loading branch information
allanc65 and DanielNoord authored Dec 3, 2021
1 parent 35813de commit 4b70feb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 3 additions & 10 deletions pylint/extensions/_check_docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-param-doc=no
docstring-min-length: -1

0 comments on commit 4b70feb

Please sign in to comment.