refactor: Move add_noqa if branch up

This commit is contained in:
Martin Fischer
2023-01-25 09:40:28 +01:00
committed by Charlie Marsh
parent b359f3a9ff
commit 4bf2879067

View File

@@ -136,7 +136,13 @@ quoting the executed command, along with the relevant file contents and `pyproje
}
let printer = Printer::new(&format, &log_level, &autofix, &violations);
if cli.watch {
if cli.add_noqa {
let modifications = commands::add_noqa(&cli.files, &pyproject_strategy, &overrides)?;
if modifications > 0 && log_level >= LogLevel::Default {
println!("Added {modifications} noqa directives.");
}
} else if cli.watch {
if !matches!(autofix, fix::FixMode::None) {
warn_user_once!("--fix is not enabled in watch mode.");
}
@@ -190,11 +196,6 @@ quoting the executed command, along with the relevant file contents and `pyproje
Err(err) => return Err(err.into()),
}
}
} else if cli.add_noqa {
let modifications = commands::add_noqa(&cli.files, &pyproject_strategy, &overrides)?;
if modifications > 0 && log_level >= LogLevel::Default {
println!("Added {modifications} noqa directives.");
}
} else {
let is_stdin = cli.files == vec![PathBuf::from("-")];