mirror of https://github.com/astral-sh/ruff
Fix D202 to remove line after docstring (#797)
This commit is contained in:
parent
826ef7da67
commit
ab825eb28d
|
|
@ -532,3 +532,37 @@ class Blah: # noqa: D203,D213
|
||||||
|
|
||||||
expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]),
|
expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]),
|
||||||
'D100: Missing docstring in public module')
|
'D100: Missing docstring in public module')
|
||||||
|
|
||||||
|
|
||||||
|
@expect('D201: No blank lines allowed before function docstring (found 1)')
|
||||||
|
@expect('D213: Multi-line docstring summary should start at the second line')
|
||||||
|
def multiline_leading_space():
|
||||||
|
|
||||||
|
"""Leading space.
|
||||||
|
|
||||||
|
More content.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@expect('D202: No blank lines allowed after function docstring (found 1)')
|
||||||
|
@expect('D213: Multi-line docstring summary should start at the second line')
|
||||||
|
def multiline_trailing_space():
|
||||||
|
"""Leading space.
|
||||||
|
|
||||||
|
More content.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@expect('D201: No blank lines allowed before function docstring (found 1)')
|
||||||
|
@expect('D202: No blank lines allowed after function docstring (found 1)')
|
||||||
|
@expect('D213: Multi-line docstring summary should start at the second line')
|
||||||
|
def multiline_trailing_and_leading_space():
|
||||||
|
|
||||||
|
"""Trailing and leading space.
|
||||||
|
|
||||||
|
More content.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -223,8 +223,11 @@ pub fn blank_before_after_function(checker: &mut Checker, definition: &Definitio
|
||||||
if checker.patch() {
|
if checker.patch() {
|
||||||
// Delete the blank line after the docstring.
|
// Delete the blank line after the docstring.
|
||||||
check.amend(Fix::deletion(
|
check.amend(Fix::deletion(
|
||||||
Location::new(docstring.location.row() + 1, 0),
|
Location::new(docstring.end_location.unwrap().row() + 1, 0),
|
||||||
Location::new(docstring.location.row() + 1 + blank_lines_after, 0),
|
Location::new(
|
||||||
|
docstring.end_location.unwrap().row() + 1 + blank_lines_after,
|
||||||
|
0,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
checker.add_check(check);
|
checker.add_check(check);
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,40 @@ expression: checks
|
||||||
row: 146
|
row: 146
|
||||||
column: 0
|
column: 0
|
||||||
applied: false
|
applied: false
|
||||||
|
- kind:
|
||||||
|
NoBlankLineBeforeFunction: 1
|
||||||
|
location:
|
||||||
|
row: 541
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 544
|
||||||
|
column: 7
|
||||||
|
fix:
|
||||||
|
patch:
|
||||||
|
content: ""
|
||||||
|
location:
|
||||||
|
row: 540
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 541
|
||||||
|
column: 0
|
||||||
|
applied: false
|
||||||
|
- kind:
|
||||||
|
NoBlankLineBeforeFunction: 1
|
||||||
|
location:
|
||||||
|
row: 563
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 566
|
||||||
|
column: 7
|
||||||
|
fix:
|
||||||
|
patch:
|
||||||
|
content: ""
|
||||||
|
location:
|
||||||
|
row: 562
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 563
|
||||||
|
column: 0
|
||||||
|
applied: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,40 @@ expression: checks
|
||||||
row: 148
|
row: 148
|
||||||
column: 0
|
column: 0
|
||||||
applied: false
|
applied: false
|
||||||
|
- kind:
|
||||||
|
NoBlankLineAfterFunction: 1
|
||||||
|
location:
|
||||||
|
row: 550
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 553
|
||||||
|
column: 7
|
||||||
|
fix:
|
||||||
|
patch:
|
||||||
|
content: ""
|
||||||
|
location:
|
||||||
|
row: 554
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 555
|
||||||
|
column: 0
|
||||||
|
applied: false
|
||||||
|
- kind:
|
||||||
|
NoBlankLineAfterFunction: 1
|
||||||
|
location:
|
||||||
|
row: 563
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 566
|
||||||
|
column: 7
|
||||||
|
fix:
|
||||||
|
patch:
|
||||||
|
content: ""
|
||||||
|
location:
|
||||||
|
row: 567
|
||||||
|
column: 0
|
||||||
|
end_location:
|
||||||
|
row: 568
|
||||||
|
column: 0
|
||||||
|
applied: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,4 +130,28 @@ expression: checks
|
||||||
row: 527
|
row: 527
|
||||||
column: 7
|
column: 7
|
||||||
fix: ~
|
fix: ~
|
||||||
|
- kind: MultiLineSummarySecondLine
|
||||||
|
location:
|
||||||
|
row: 541
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 544
|
||||||
|
column: 7
|
||||||
|
fix: ~
|
||||||
|
- kind: MultiLineSummarySecondLine
|
||||||
|
location:
|
||||||
|
row: 550
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 553
|
||||||
|
column: 7
|
||||||
|
fix: ~
|
||||||
|
- kind: MultiLineSummarySecondLine
|
||||||
|
location:
|
||||||
|
row: 563
|
||||||
|
column: 4
|
||||||
|
end_location:
|
||||||
|
row: 566
|
||||||
|
column: 7
|
||||||
|
fix: ~
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue