Skip to content

[D214, D405, D417] False positive with arg keyword attributes #16007

@JP-Ellis

Description

@JP-Ellis

Summary

If using Google style and putting the argument's description on a new line, then if one argument is attributes, it raises D214 and D405.

I raised a similar issue previously (#8457), and this appears to another related edge case.

Example

ruff.toml
[lint.pydocstyle]
convention = "google"
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.
    """
ruff check --config config.toml --select ALL ruff.py 
ruff.py:1:5: D417 Missing argument description in the docstring for `send`: `attributes`
  |
1 | def send(payload: str, attributes: dict[str, Any]) -> None:
  |     ^^^^ D417
2 |     """
3 |     Send a message.
  |
ruff.py:9:9: D405 [*] Section name should be properly capitalized ("attributes")
   |
 7 |             The message payload.
 8 |
 9 |         attributes:
   |         ^^^^^^^^^^ D405
10 |             Additional attributes to be sent alongside the message.
11 |     """
   |
   = help: Capitalize "attributes"

ruff.py:9:9: D214 [*] Section is over-indented ("attributes")
   |
 7 |             The message payload.
 8 |
 9 |         attributes:
   |         ^^^^^^^^^^ D214
10 |             Additional attributes to be sent alongside the message.
11 |     """
   |
   = help: Remove over-indentation from "attributes"

Found 6 errors.

Note that I omitted a couple of expected errors (such as an undefined 'Any')

ruff --version
ruff 0.9.3

Related

This is related (nearly identical) to #8457.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocstringRelated to docstring linting or formatting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions