diff --git a/crates/ruff/src/rules/pydocstyle/rules/indent.rs b/crates/ruff/src/rules/pydocstyle/rules/indent.rs index 567449d7602aa..92fc84ce10beb 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/indent.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/indent.rs @@ -131,10 +131,14 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) { let mut diagnostic = Diagnostic::new(OverIndentation, TextRange::empty(over_indented.start())); if checker.patch(diagnostic.kind.rule()) { - diagnostic.set_fix(Edit::range_replacement( - whitespace::clean(docstring.indentation), - over_indented, - )); + let new_indent = whitespace::clean(docstring.indentation); + + let edit = if new_indent.is_empty() { + Edit::range_deletion(over_indented) + } else { + Edit::range_replacement(new_indent, over_indented) + }; + diagnostic.set_fix(edit); } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff/src/rules/pydocstyle/rules/sections.rs index 74f73d84e82d0..abfd5b827aa8e 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/sections.rs @@ -534,7 +534,7 @@ fn blanks_and_section_underline( ); if checker.patch(diagnostic.kind.rule()) { let range = - TextRange::at(context.following_range().start(), blank_lines_end); + TextRange::new(context.following_range().start(), blank_lines_end); // Delete any blank lines between the header and content. diagnostic.set_fix(Edit::range_deletion(range)); }