Fix D202 to remove line after docstring (#797)

This commit is contained in:
Charlie Marsh 2022-11-17 15:01:58 -05:00 committed by GitHub
parent 826ef7da67
commit ab825eb28d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 135 additions and 2 deletions

View File

@ -532,3 +532,37 @@ class Blah: # noqa: D203,D213
expect(os.path.normcase(__file__ if __file__[-1] != 'c' else __file__[:-1]),
'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

View File

@ -223,8 +223,11 @@ pub fn blank_before_after_function(checker: &mut Checker, definition: &Definitio
if checker.patch() {
// Delete the blank line after the docstring.
check.amend(Fix::deletion(
Location::new(docstring.location.row() + 1, 0),
Location::new(docstring.location.row() + 1 + blank_lines_after, 0),
Location::new(docstring.end_location.unwrap().row() + 1, 0),
Location::new(
docstring.end_location.unwrap().row() + 1 + blank_lines_after,
0,
),
));
}
checker.add_check(check);

View File

@ -38,4 +38,40 @@ expression: checks
row: 146
column: 0
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

View File

@ -38,4 +38,40 @@ expression: checks
row: 148
column: 0
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

View File

@ -130,4 +130,28 @@ expression: checks
row: 527
column: 7
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: ~