Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit ac56b83

Browse files
authored
Fix bug with google style arg regex (#448)
Currently, due to the way the regex was specified, the regex matcher was getting thrown off by types that used colons. This change makes the regex robust to such type and fixes #443
1 parent ebc5466 commit ac56b83

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

docs/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Bug Fixes
1515

1616
* Update convention support documentation (#386, #393)
1717
* Detect inner asynchronous functions for D202 (#467)
18+
* Fix a bug in parsing Google-style argument description.
19+
The bug caused some argument names to go unreported in D417 (#448).
1820

1921
5.0.2 - January 8th, 2020
2022
---------------------------

src/pydocstyle/checker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ class ConventionChecker:
9696
r"(\w+)" # Followed by 1 or more unicode chars, numbers or underscores
9797
# The above is captured as the first group as this is the paramater name.
9898
r"\s*" # Followed by 0 or more whitespace characters
99-
r"\(?(.*?)\)?" # Matches patterns contained within round brackets.
100-
# The `(.*?)` is the second capturing group which matches any sequence of
101-
# characters in a non-greedy way (denoted by the `*?`)
99+
r"(\(.*?\))?" # Matches patterns contained within round brackets.
100+
# The `.*?`matches any sequence of characters in a non-greedy
101+
# way (denoted by the `*?`)
102102
r"\s*" # Followed by 0 or more whitespace chars
103103
r":" # Followed by a colon
104104
".+" # Followed by 1 or more characters - which is the docstring for the parameter

src/tests/test_cases/sections.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,36 @@ def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407
335335
336336
"""
337337

338+
@staticmethod
339+
@expect("D417: Missing argument descriptions in the docstring "
340+
"(argument(s) a, b are missing descriptions in "
341+
"'test_missing_docstring' docstring)", arg_count=2)
342+
def test_missing_docstring(a, b): # noqa: D213, D407
343+
"""Test a valid args section.
344+
345+
Args:
346+
a:
347+
348+
"""
349+
350+
@staticmethod
351+
@expect("D417: Missing argument descriptions in the docstring "
352+
"(argument(s) skip, verbose are missing descriptions in "
353+
"'test_missing_docstring_another' docstring)", arg_count=2)
354+
def test_missing_docstring_another(skip, verbose): # noqa: D213, D407
355+
"""Do stuff.
356+
357+
Args:
358+
skip (:attr:`.Skip`):
359+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
360+
Etiam at tellus a tellus faucibus maximus. Curabitur tellus
361+
mauris, semper id vehicula ac, feugiat ut tortor.
362+
verbose (bool):
363+
If True, print out as much infromation as possible.
364+
If False, print out concise "one-liner" information.
365+
366+
"""
367+
338368

339369
@expect(_D213)
340370
@expect("D417: Missing argument descriptions in the docstring "

0 commit comments

Comments
 (0)