-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic in pydocstyle D214 when docstring indentation is empty (#4216)
- Loading branch information
Showing
4 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
crates/ruff/resources/test/fixtures/pydocstyle/D214_module.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""A module docstring with D214 violations | ||
Returns | ||
----- | ||
valid returns | ||
Args | ||
----- | ||
valid args | ||
""" | ||
|
||
import os | ||
from .expected import Expectation | ||
|
||
expectation = Expectation() | ||
expect = expectation.expect | ||
|
||
expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]), | ||
"D214: Section is over-indented ('Returns')") | ||
expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]), | ||
"D214: Section is over-indented ('Args')") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...f/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_D214_module.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
source: crates/ruff/src/rules/pydocstyle/mod.rs | ||
--- | ||
D214_module.py:1:1: D214 [*] Section is over-indented ("Returns") | ||
| | ||
1 | / """A module docstring with D214 violations | ||
2 | | | ||
3 | | Returns | ||
4 | | ----- | ||
5 | | valid returns | ||
6 | | | ||
7 | | Args | ||
8 | | ----- | ||
9 | | valid args | ||
10 | | """ | ||
| |___^ D214 | ||
11 | | ||
12 | import os | ||
| | ||
= help: Remove over-indentation from "Returns" | ||
|
||
ℹ Suggested fix | ||
1 1 | """A module docstring with D214 violations | ||
2 2 | | ||
3 |- Returns | ||
3 |+Returns | ||
4 4 | ----- | ||
5 5 | valid returns | ||
6 6 | | ||
|
||
D214_module.py:1:1: D214 [*] Section is over-indented ("Args") | ||
| | ||
1 | / """A module docstring with D214 violations | ||
2 | | | ||
3 | | Returns | ||
4 | | ----- | ||
5 | | valid returns | ||
6 | | | ||
7 | | Args | ||
8 | | ----- | ||
9 | | valid args | ||
10 | | """ | ||
| |___^ D214 | ||
11 | | ||
12 | import os | ||
| | ||
= help: Remove over-indentation from "Args" | ||
|
||
ℹ Suggested fix | ||
4 4 | ----- | ||
5 5 | valid returns | ||
6 6 | | ||
7 |- Args | ||
7 |+Args | ||
8 8 | ----- | ||
9 9 | valid args | ||
10 10 | """ | ||