Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid re-indenting empty lines in D207 #517

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pydocstyle/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {

// Omit empty lines, except for the last line, which is non-empty by way of
// containing the closing quotation marks.
if i < lines.len() - 1 && lines[i].trim().is_empty() {
let is_blank = lines[i].trim().is_empty();
if i < lines.len() - 1 && is_blank {
continue;
}

Expand All @@ -416,7 +417,7 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {
if checker.settings.enabled.contains(&CheckCode::D207) {
// We report under-indentation on every line. This isn't great, but enables
// autofix.
if line_indent.len() < docstring_indent.len() {
if !is_blank && line_indent.len() < docstring_indent.len() {
let mut check = Check::new(
CheckKind::NoUnderIndentation,
Range {
Expand Down
34 changes: 0 additions & 34 deletions src/snapshots/ruff__linter__tests__D207_D.py.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,6 @@ expression: checks
row: 227
column: 1
applied: false
- kind: NoUnderIndentation
location:
row: 238
column: 1
end_location:
row: 238
column: 1
fix:
patch:
content: " "
location:
row: 238
column: 1
end_location:
row: 238
column: 1
applied: false
- kind: NoUnderIndentation
location:
row: 435
Expand All @@ -53,21 +36,4 @@ expression: checks
row: 435
column: 5
applied: false
- kind: NoUnderIndentation
location:
row: 436
column: 1
end_location:
row: 436
column: 1
fix:
patch:
content: " "
location:
row: 436
column: 1
end_location:
row: 436
column: 5
applied: false