mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00

## 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.
220 lines
3.3 KiB
Python
220 lines
3.3 KiB
Python
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
with a hanging indent
|
|
|
|
Returns:
|
|
the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x:
|
|
The whole thing has a hanging indent.
|
|
|
|
Returns:
|
|
the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x:
|
|
The whole thing has a hanging indent.
|
|
|
|
Returns: the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value def
|
|
ghi
|
|
|
|
Returns:
|
|
the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
z: A final argument
|
|
|
|
Returns:
|
|
the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
z: A final argument
|
|
|
|
Returns: the value
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
z: A final argument
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, *args, **kwargs):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
*args: variable arguments
|
|
**kwargs: keyword arguments
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, *args, **kwargs):
|
|
"""Do something.
|
|
|
|
Args:
|
|
*args: variable arguments
|
|
**kwargs: keyword arguments
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, *args, **kwargs):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
**kwargs: keyword arguments
|
|
"""
|
|
return x
|
|
|
|
|
|
def f(x, *, y, z):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: some first value
|
|
|
|
Keyword Args:
|
|
y (int): the other value
|
|
z (int): the last value
|
|
|
|
"""
|
|
return x, y, z
|
|
|
|
def f(x):
|
|
"""Do something with valid description.
|
|
|
|
Args:
|
|
----
|
|
x: the value
|
|
|
|
Returns:
|
|
-------
|
|
the value
|
|
"""
|
|
return x
|
|
|
|
|
|
class Test:
|
|
def f(self, /, arg1: int) -> None:
|
|
"""
|
|
Some beauty description.
|
|
|
|
Args:
|
|
arg1: some description of arg
|
|
"""
|
|
|
|
|
|
def select_data(
|
|
query: str,
|
|
args: tuple,
|
|
database: str,
|
|
auto_save: bool,
|
|
) -> None:
|
|
"""This function has an argument `args`, which shouldn't be mistaken for a section.
|
|
|
|
Args:
|
|
query:
|
|
Query template.
|
|
args:
|
|
A list of arguments.
|
|
database:
|
|
Which database to connect to ("origin" or "destination").
|
|
"""
|
|
|
|
def f(x, *args, **kwargs):
|
|
"""Do something.
|
|
|
|
Args:
|
|
x: the value
|
|
*args: var-arguments
|
|
"""
|
|
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.
|
|
"""
|