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

Fix false positive of google convention missing args descriptions #619

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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