[`pydocstyle`] Skip `overload-with-docstring` in stub files (`D418`) (#26318)
Closes #26153.
`D418` (`overload-with-docstring`) currently fires inside stub files
(`.pyi`),
but stubs do not have a non-overloaded "implementation" definition that
could
carry the shared docstring — type checkers such as mypy and zuban
actively
reject that pattern in stubs. The only place the docstring can live is
on one
of the overloads, so flagging it as a violation is a false positive.
This change adds a stub-file early-exit to the `D418` entry point,
matching
the established pattern used elsewhere in `ruff_linter` (e.g.
`S401`–`S413`,
`B006`, `FBT001`, `FBT002`, and many `flake8_pyi` rules).
This matches the maintainer steer in the issue thread:
> Huh. I think Ruff should probably just refrain from enforcing this
rule on
> stub files. Overloaded functions never have implementations in stub
files.
> Mypy and zuban actually emit errors if you try to do so […]
>
> — @AlexWaygood
## Test plan
- Added a fixture `D418.pyi` containing module-level, method, and nested
overloaded functions, each with a docstring on the last overload.
- Added a corresponding `#[test_case]` and an empty insta snapshot.
- The pre-existing `D.py` fixture / snapshot are unchanged — `.py`
behaviour
is identical, no regression.
```text
$ cargo test -p ruff_linter --lib \
"pydocstyle::tests::rules::rule_overloadwithdocstring"
running 2 tests
test rules::pydocstyle::tests::rules::rule_overloadwithdocstring_path_new_d418_pyi_expects ... ok
test rules::pydocstyle::tests::rules::rule_overloadwithdocstring_path_new_d_py_expects ... ok
test result: ok. 2 passed; 0 failed