mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:04:51 +00:00
Don't prompt users to --fix if they ran with --fix (#1133)
This commit is contained in:
parent
528416f07a
commit
3152dd7a8e
2 changed files with 7 additions and 7 deletions
|
@ -392,7 +392,7 @@ fn inner_main() -> Result<ExitCode> {
|
||||||
// unless we're writing fixes via stdin (in which case, the transformed
|
// unless we're writing fixes via stdin (in which case, the transformed
|
||||||
// source code goes to stdout).
|
// source code goes to stdout).
|
||||||
if !(is_stdin && matches!(autofix, fixer::Mode::Apply)) {
|
if !(is_stdin && matches!(autofix, fixer::Mode::Apply)) {
|
||||||
printer.write_once(&diagnostics)?;
|
printer.write_once(&diagnostics, &autofix)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates if we're in a non-silent log level.
|
// Check for updates if we're in a non-silent log level.
|
||||||
|
|
|
@ -9,7 +9,7 @@ use itertools::iterate;
|
||||||
use rustpython_parser::ast::Location;
|
use rustpython_parser::ast::Location;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::{fixer, Fix};
|
||||||
use crate::checks::CheckCode;
|
use crate::checks::CheckCode;
|
||||||
use crate::fs::relativize_path;
|
use crate::fs::relativize_path;
|
||||||
use crate::linter::Diagnostics;
|
use crate::linter::Diagnostics;
|
||||||
|
@ -57,15 +57,15 @@ impl<'a> Printer<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn post_text(&self, num_fixable: usize) {
|
fn post_text(&self, num_fixable: usize, autofix: &fixer::Mode) {
|
||||||
if self.log_level >= &LogLevel::Default {
|
if self.log_level >= &LogLevel::Default {
|
||||||
if num_fixable > 0 {
|
if num_fixable > 0 && !matches!(autofix, fixer::Mode::Apply) {
|
||||||
println!("{num_fixable} potentially fixable with the --fix option.");
|
println!("{num_fixable} potentially fixable with the --fix option.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_once(&self, diagnostics: &Diagnostics) -> Result<()> {
|
pub fn write_once(&self, diagnostics: &Diagnostics, autofix: &fixer::Mode) -> Result<()> {
|
||||||
if matches!(self.log_level, LogLevel::Silent) {
|
if matches!(self.log_level, LogLevel::Silent) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ impl<'a> Printer<'a> {
|
||||||
print_message(message);
|
print_message(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.post_text(num_fixable);
|
self.post_text(num_fixable, autofix);
|
||||||
}
|
}
|
||||||
SerializationFormat::Grouped => {
|
SerializationFormat::Grouped => {
|
||||||
self.pre_text(diagnostics);
|
self.pre_text(diagnostics);
|
||||||
|
@ -190,7 +190,7 @@ impl<'a> Printer<'a> {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.post_text(num_fixable);
|
self.post_text(num_fixable, autofix);
|
||||||
}
|
}
|
||||||
SerializationFormat::Github => {
|
SerializationFormat::Github => {
|
||||||
self.pre_text(diagnostics);
|
self.pre_text(diagnostics);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue