diff --git a/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs b/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs index e3dc01bf540ebe..2ea5fa6d56344b 100644 --- a/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs +++ b/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs @@ -5,7 +5,6 @@ use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; -use crate::registry::AsRule; /// ## What it does /// @@ -193,26 +192,23 @@ pub(crate) fn numpy_2_0_deprecation(checker: &mut Checker, expr: &Expr) { }, expr.range(), ); - - if checker.patch(diagnostic.kind.rule()) { - match replacement.details { - Details::AutoImport { path, name } => { - diagnostic.try_set_fix(|| { - let (import_edit, binding) = checker.importer().get_or_import_symbol( - &ImportRequest::import_from(path, name), - expr.start(), - checker.semantic(), - )?; - let replacement_edit = Edit::range_replacement(binding, expr.range()); - Ok(Fix::suggested_edits(import_edit, [replacement_edit])) - }); - } - Details::AutoPurePython { python_expr } => diagnostic.set_fix(Fix::suggested( - Edit::range_replacement(python_expr.to_string(), expr.range()), - )), - Details::Manual { guideline: _ } => {} + match replacement.details { + Details::AutoImport { path, name } => { + diagnostic.try_set_fix(|| { + let (import_edit, binding) = checker.importer().get_or_import_symbol( + &ImportRequest::import_from(path, name), + expr.start(), + checker.semantic(), + )?; + let replacement_edit = Edit::range_replacement(binding, expr.range()); + Ok(Fix::safe_edits(import_edit, [replacement_edit])) + }); } - } + Details::AutoPurePython { python_expr } => diagnostic.set_fix(Fix::safe_edit( + Edit::range_replacement(python_expr.to_string(), expr.range()), + )), + Details::Manual { guideline: _ } => {} + }; checker.diagnostics.push(diagnostic); } }