Use a separate PrinterFlag for including fix diffs (#4615)

This commit is contained in:
Charlie Marsh 2023-05-24 10:22:37 -04:00 committed by GitHub
parent 8961d8eb6f
commit 040fb9cef4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 33 deletions

View file

@ -155,13 +155,6 @@ fn format(files: &[PathBuf]) -> Result<ExitStatus> {
}
fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
let ecosystem_ci = args.ecosystem_ci;
if ecosystem_ci {
warn_user_once!(
"The formatting of fixes emitted by this option is a work-in-progress, subject to \
change at any time, and intended for use with the ecosystem ci scripts only."
);
}
let (cli, overrides) = args.partition();
// Construct the "default" settings. These are used when no `pyproject.toml`
@ -219,11 +212,18 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
printer_flags |= PrinterFlags::SHOW_VIOLATIONS;
}
if show_fixes {
printer_flags |= PrinterFlags::SHOW_FIXES;
printer_flags |= PrinterFlags::SHOW_FIX_SUMMARY;
}
if show_source {
printer_flags |= PrinterFlags::SHOW_SOURCE;
}
if cli.ecosystem_ci {
warn_user_once!(
"The formatting of fixes emitted by this option is a work-in-progress, subject to \
change at any time, and intended only for internal use."
);
printer_flags |= PrinterFlags::SHOW_FIX_DIFF;
}
#[cfg(debug_assertions)]
if cache {
@ -248,7 +248,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
return Ok(ExitStatus::Success);
}
let printer = Printer::new(format, log_level, autofix, printer_flags, ecosystem_ci);
let printer = Printer::new(format, log_level, autofix, printer_flags);
if cli.watch {
if format != SerializationFormat::Text {