diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 5f35814..7aa2b0f 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -5,6 +5,13 @@ Release Notes `Semantic Versioning `_ specification. +Current development version +--------------------------- + +Bug Fixes + +* Fix false positives of D417 in google convention docstrings (#619). + 6.2.1 - January 3rd, 2023 --------------------------- diff --git a/src/pydocstyle/checker.py b/src/pydocstyle/checker.py index 0b45644..5cefc76 100644 --- a/src/pydocstyle/checker.py +++ b/src/pydocstyle/checker.py @@ -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): diff --git a/src/tests/test_cases/sections.py b/src/tests/test_cases/sections.py index b493260..5bf9a7b 100644 --- a/src/tests/test_cases/sections.py +++ b/src/tests/test_cases/sections.py @@ -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)