mirror of https://github.com/astral-sh/ruff
Mark `--add-noqa` as incompatible with `--fix` (#2513)
This commit is contained in:
parent
7e9b9cc7b3
commit
a30c77e752
|
|
@ -237,6 +237,7 @@ pub struct CheckArgs {
|
|||
conflicts_with = "statistics",
|
||||
conflicts_with = "stdin_filename",
|
||||
conflicts_with = "watch",
|
||||
conflicts_with = "fix",
|
||||
)]
|
||||
pub add_noqa: bool,
|
||||
/// See the files Ruff will be run against with the current settings.
|
||||
|
|
|
|||
|
|
@ -160,9 +160,12 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitCode> {
|
|||
}
|
||||
|
||||
if cli.add_noqa {
|
||||
if !matches!(autofix, fix::FixMode::None) {
|
||||
warn_user_once!("--fix is incompatible with --add-noqa.");
|
||||
}
|
||||
let modifications = commands::add_noqa(&cli.files, &pyproject_strategy, &overrides)?;
|
||||
if modifications > 0 && log_level >= LogLevel::Default {
|
||||
println!("Added {modifications} noqa directives.");
|
||||
eprintln!("Added {modifications} noqa directives.");
|
||||
}
|
||||
return Ok(ExitCode::SUCCESS);
|
||||
}
|
||||
|
|
@ -171,7 +174,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitCode> {
|
|||
|
||||
if cli.watch {
|
||||
if !matches!(autofix, fix::FixMode::None) {
|
||||
warn_user_once!("--fix is not enabled in watch mode.");
|
||||
warn_user_once!("--fix is unsupported in watch mode.");
|
||||
}
|
||||
if format != SerializationFormat::Text {
|
||||
warn_user_once!("--format 'text' is used in watch mode.");
|
||||
|
|
|
|||
|
|
@ -196,7 +196,6 @@ fn add_noqa_inner(
|
|||
output.push_str(line_ending);
|
||||
}
|
||||
Directive::Codes(_, start_byte, _, existing) => {
|
||||
println!("existing: {:?}", existing);
|
||||
// Reconstruct the line based on the preserved rule codes.
|
||||
// This enables us to tally the number of edits.
|
||||
let mut formatted = String::with_capacity(line.len());
|
||||
|
|
|
|||
Loading…
Reference in New Issue