ruff/crates/ruff_linter/resources/test/fixtures/pydocstyle
Phong Do 45fb3732a4
[`pydocstyle`] Suppress `D417` for parameters with `Unpack` annotations (#21816)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

Fixes https://github.com/astral-sh/ruff/issues/8774

This PR fixes `pydocstyle` incorrectly flagging missing argument for
arguments with `Unpack` type annotation by extracting the `kwarg` `D417`
suppression logic into a helper function for future rules as needed.

## Problem Statement

The below example was incorrectly triggering `D417` error for missing
`**kwargs` doc.

```python
class User(TypedDict):
    id: int
    name: str

def do_something(some_arg: str, **kwargs: Unpack[User]):
    """Some doc
    
    Args:
        some_arg: Some argument
    """
```

<img width="1135" height="276" alt="image"
src="https://github.com/user-attachments/assets/42fa4bb9-61a5-4a70-a79c-0c8922a3ee66"
/>

`**kwargs: Unpack[User]` indicates the function expects keyword
arguments that will be unpacked. Ideally, the individual fields of the
User `TypedDict` should be documented, not in the `**kwargs` itself. The
`**kwargs` parameter acts as a semantic grouping rather than a parameter
requiring documentation.

## Solution

As discussed in the linked issue, it makes sense to suppress the `D417`
for parameters with `Unpack` annotation. I extract a helper function to
solely check `D417` should be suppressed with `**kwarg: Unpack[T]`
parameter, this function can also be unit tested independently and
reduce complexity of current `missing_args` check function. This also
makes it easier to add additional rules in the future.

_✏️ Note:_ This is my first PR in this repo, as I've learned a ton from
it, please call out anything that could be improved. Thanks for making
this excellent tool 👏

## Test Plan

Add 2 test cases in `D417.py` and update snapshots.

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
2025-12-08 19:00:05 +00:00
..
D104 Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
_unrelated Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D.py [`pydoclint`] Fix `SyntaxError` from fixes with line continuations (`D201`, `D202`) (#19246) 2025-07-14 13:31:36 -04:00
D100.ipynb Avoid `D100` for Jupyter Notebooks (#8816) 2023-11-22 15:26:25 +00:00
D200.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D202.py Rename rules currently not conforming to naming convention (#15102) 2024-12-23 15:48:45 -06:00
D208.py Don't raise `D208` when last line is non-empty (#13372) 2024-09-26 14:53:21 +02:00
D209_D400.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D214_module.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D215.py Use deletion for D215 full-line removals (#7625) 2023-09-23 22:44:55 +00:00
D300.py `D300`: prevent autofix when both triples are in body (#8462) 2023-11-03 12:49:50 -04:00
D301.py [pydocstyle] Escaped docstring in docstring (D301 ) (#12192) 2024-07-18 18:36:05 -04:00
D400.py Ignore underlines when determining docstring logical lines (#8929) 2023-11-30 14:27:04 -05:00
D400_415.py [pycodestyle] Fix: Don't autofix if the first line ends in a question mark? (D400) (#13399) 2024-09-20 11:05:26 +00:00
D401.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D402.py Respect word boundaries when detecting function signature in docs (#13388) 2024-09-18 00:01:38 -04:00
D403.py [`pydocstyle`] Split on first whitespace character (`D403`) (#15082) 2024-12-20 12:55:50 -06:00
D410.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
D413.py [`pydocstyle`] Fix D413 infinite loop for parenthesized docstring (#18930) 2025-06-30 10:49:13 -04:00
D417.py [`pydocstyle`] Suppress `D417` for parameters with `Unpack` annotations (#21816) 2025-12-08 19:00:05 +00:00
all.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
bom.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
canonical_google_examples.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
canonical_numpy_examples.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
sections.py Avoid treating newline-separated sections as sub-sections (#15311) 2025-01-06 22:13:35 -05:00
setter.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
sphinx.py Avoid removing newlines between docstring headers and rST blocks (#11609) 2024-05-30 13:29:20 -04:00