Skip to content

Commit 4b70feb

Browse files
#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 <[email protected]>
1 parent 35813de commit 4b70feb

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

CONTRIBUTORS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,6 @@ contributors:
582582
* Harshil (harshil21): contributor
583583

584584
* Felix von Drigalski (felixvd): contributor
585+
586+
* Allan Chandler (allanc65): contributor
587+
- Fixed issue 5452, false positive missing-param-doc for multi-line Google-style params

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Release date: TBA
3939

4040
Closes #5437
4141

42+
* Fixed handling of Google-style parameter specifications where descriptions
43+
are on the line following the parameter name. These were generating
44+
false positives for ``missing-param-doc``.
45+
46+
Closes #5452
47+
4248
..
4349
Insert your changelog randomly, it will reduce merge conflicts
4450
(Ie. not necessarily at the end)

pylint/extensions/_check_docs_utils.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,16 +646,9 @@ def match_param_docs(self):
646646
if not match:
647647
continue
648648

649-
# check if parameter has description only
650-
re_only_desc = re.search(":\n", entry)
651-
if re_only_desc:
652-
param_name = match.group(1)
653-
param_desc = match.group(2)
654-
param_type = None
655-
else:
656-
param_name = match.group(1)
657-
param_type = match.group(2)
658-
param_desc = match.group(3)
649+
param_name = match.group(1)
650+
param_type = match.group(2)
651+
param_desc = match.group(3)
659652

660653
if param_type:
661654
params_with_type.add(param_name)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Tests for missing-param-doc and missing-type-doc for Google style docstrings
2+
with accept-no-param-doc = no
3+
4+
Styleguide:
5+
https://google.github.io/styleguide/pyguide.html#doc-function-args
6+
"""
7+
# pylint: disable=invalid-name
8+
9+
10+
def test_multi_line_parameters(param: int) -> None:
11+
"""Checks that multi line parameters lists are checked correctly
12+
See https://github.com/PyCQA/pylint/issues/5452
13+
14+
Args:
15+
param:
16+
a description
17+
"""
18+
print(param)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
3+
4+
[BASIC]
5+
accept-no-param-doc=no
6+
docstring-min-length: -1

0 commit comments

Comments
 (0)