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

Commit

Permalink
Fix false positive of google convention missing args descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
stinovlas committed Jan 3, 2023
1 parent 45fbcc1 commit bfd113d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/release_notes.rst
Expand Up @@ -5,6 +5,13 @@ Release Notes
`Semantic Versioning <http://semver.org/>`_ specification.


Current development version
---------------------------

Bug Fixes

* Fix false positives of D417 in google convention docstrings (#619).

6.2.1 - January 3rd, 2023
---------------------------

Expand Down
16 changes: 15 additions & 1 deletion src/pydocstyle/checker.py
Expand Up @@ -862,8 +862,22 @@ def _check_args_section(docstring, definition, context):
y: Ut enim ad minim veniam
"""
docstring_args = set()

# normalize leading whitespace
args_content = dedent("\n".join(context.following_lines)).strip()
if context.following_lines:
# any lines with shorter indent than the first one should be disregarded
first_line = context.following_lines[0]
leading_whitespaces = first_line[: -len(first_line.lstrip())]

args_content = dedent(
"\n".join(
[
line
for line in context.following_lines
if line.startswith(leading_whitespaces) or line == ""
]
)
).strip()

args_sections = []
for line in args_content.splitlines(keepends=True):
Expand Down
11 changes: 11 additions & 0 deletions src/tests/test_cases/sections.py
Expand Up @@ -318,6 +318,17 @@ def test_method(self, test, another_test, _): # noqa: D213, D407
"""

def test_detailed_description(self, test, another_test, _): # noqa: D213, D407
"""Test a valid args section.
Args:
test: A parameter.
another_test: Another parameter.
Detailed description.
"""

@expect("D417: Missing argument descriptions in the docstring "
"(argument(s) test, y, z are missing descriptions in "
"'test_missing_args' docstring)", arg_count=5)
Expand Down

0 comments on commit bfd113d

Please sign in to comment.