[pydocstyle] Fix D413 infinite loop for parenthesized docstring (#18930)

<!--
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

<!-- What's the purpose of the change? What does it do, and why? -->

Fixes #18908
This commit is contained in:
Dan Parizher 2025-06-30 10:49:13 -04:00 committed by GitHub
parent eb9d9c3646
commit 9f0d3cca89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 2 deletions

View file

@ -69,3 +69,11 @@ def func():
Returns:
the value
"""
def func():
("""Docstring.
Raises:
ValueError: An error.
""")

View file

@ -1717,7 +1717,7 @@ fn common_section(
format!(
"{}{}",
line_end.repeat(2 - num_blank_lines),
docstring.compute_indentation()
leading_space(docstring.compute_indentation())
),
context.end() - del_len,
context.end(),

View file

@ -79,5 +79,27 @@ D413.py:69:5: D413 [*] Missing blank line after last section ("Returns")
69 69 | Returns:
70 70 | the value
71 |- """
71 |+
72 71 |
72 |+ """
73 |+
73 74 |
74 75 | def func():
75 76 | ("""Docstring.
D413.py:77:5: D413 [*] Missing blank line after last section ("Raises")
|
75 | ("""Docstring.
76 |
77 | Raises:
| ^^^^^^ D413
78 | ValueError: An error.
79 | """)
|
= help: Add blank line after "Raises"
Safe fix
76 76 |
77 77 | Raises:
78 78 | ValueError: An error.
79 |+
79 80 | """)