Skip to content

Commit

Permalink
Update Diff output to account for applicability of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed May 9, 2023
1 parent 36540b2 commit b51fa31
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/ruff/src/message/diff.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::message::Message;
use colored::{Color, ColoredString, Colorize, Styles};
use ruff_diagnostics::Fix;
use ruff_diagnostics::{Fix, Applicability};
use ruff_python_ast::source_code::{OneIndexed, SourceFile};
use ruff_text_size::{TextRange, TextSize};
use similar::{ChangeTag, TextDiff};
Expand Down Expand Up @@ -47,8 +47,14 @@ impl Display for Diff<'_> {

let diff = TextDiff::from_lines(self.source_code.source_text(), &output);

writeln!(f, "{}", "ℹ Suggested fix".blue())?;

let message = match self.fix.applicability() {
Applicability::Automatic => "Fix",
Applicability::Suggested => "Suggested fix",
Applicability::Manual => "Possible fix",
_ => "Suggested fix", // For backwards compatibility, unspecified fixes are 'suggested'
};
writeln!(f, "ℹ {}", message.blue())?;

let (largest_old, largest_new) = diff
.ops()
.last()
Expand Down

0 comments on commit b51fa31

Please sign in to comment.