[pydocstyle] Handle arguments with the same names as sections (D417) (#16011)

## Summary

Fixes #16007. The logic from the last fix for this (#9427) was
sufficient, it just wasn't being applied because `Attributes` sections
aren't expected to have nested sections. I just deleted the outer
conditional, which should hopefully fix this for all section types.

## Test Plan

New regression test, plus the existing D417 tests.
This commit is contained in:
Brent Westbrook 2025-02-11 12:05:29 -05:00 committed by GitHub
parent df1d430294
commit 7b487d853a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 150 additions and 77 deletions

View file

@ -176,4 +176,45 @@ def f(x, *args, **kwargs):
x: the value
*args: var-arguments
"""
return x
return x
# regression test for https://github.com/astral-sh/ruff/issues/16007.
# attributes is a section name without subsections, so it was failing the
# previous workaround for Args: args: sections
def send(payload: str, attributes: dict[str, Any]) -> None:
"""
Send a message.
Args:
payload:
The message payload.
attributes:
Additional attributes to be sent alongside the message.
"""
# undocumented argument with the same name as a section
def should_fail(payload, Args):
"""
Send a message.
Args:
payload:
The message payload.
"""
# documented argument with the same name as a section
def should_not_fail(payload, Args):
"""
Send a message.
Args:
payload:
The message payload.
Args:
The other arguments.
"""