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

Commit 0107fe6

Browse files
authored
Fix false positive of google convention missing args descriptions (#619)
1 parent 45fbcc1 commit 0107fe6

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

docs/release_notes.rst

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Release Notes
55
`Semantic Versioning <http://semver.org/>`_ specification.
66

77

8+
Current development version
9+
---------------------------
10+
11+
Bug Fixes
12+
13+
* Fix false positives of D417 in google convention docstrings (#619).
14+
815
6.2.1 - January 3rd, 2023
916
---------------------------
1017

src/pydocstyle/checker.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,22 @@ def _check_args_section(docstring, definition, context):
862862
y: Ut enim ad minim veniam
863863
"""
864864
docstring_args = set()
865+
865866
# normalize leading whitespace
866-
args_content = dedent("\n".join(context.following_lines)).strip()
867+
if context.following_lines:
868+
# any lines with shorter indent than the first one should be disregarded
869+
first_line = context.following_lines[0]
870+
leading_whitespaces = first_line[: -len(first_line.lstrip())]
871+
872+
args_content = dedent(
873+
"\n".join(
874+
[
875+
line
876+
for line in context.following_lines
877+
if line.startswith(leading_whitespaces) or line == ""
878+
]
879+
)
880+
).strip()
867881

868882
args_sections = []
869883
for line in args_content.splitlines(keepends=True):

src/tests/test_cases/sections.py

+11
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,17 @@ def test_method(self, test, another_test, _): # noqa: D213, D407
318318
319319
"""
320320

321+
def test_detailed_description(self, test, another_test, _): # noqa: D213, D407
322+
"""Test a valid args section.
323+
324+
Args:
325+
test: A parameter.
326+
another_test: Another parameter.
327+
328+
Detailed description.
329+
330+
"""
331+
321332
@expect("D417: Missing argument descriptions in the docstring "
322333
"(argument(s) test, y, z are missing descriptions in "
323334
"'test_missing_args' docstring)", arg_count=5)

0 commit comments

Comments
 (0)