Skip to content

Commit cbca58d

Browse files
committed
feat(AIR302): add autofix to AIR302 check_method
1 parent 640d821 commit cbca58d

File tree

2 files changed

+285
-29
lines changed

2 files changed

+285
-29
lines changed

crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Violation for Airflow3Removal {
7272
}
7373
}
7474

75-
#[derive(Debug, Eq, PartialEq)]
75+
#[derive(Debug, Clone, Eq, PartialEq)]
7676
enum Replacement {
7777
None,
7878
Name(&'static str),
@@ -504,13 +504,21 @@ fn check_method(checker: &Checker, call_expr: &ExprCall) {
504504
}
505505
}
506506
};
507-
checker.report_diagnostic(Diagnostic::new(
507+
508+
let mut diagnostic = Diagnostic::new(
508509
Airflow3Removal {
509510
deprecated: attr.to_string(),
510-
replacement,
511+
replacement: replacement.clone(),
511512
},
512513
attr.range(),
513-
));
514+
);
515+
if let Replacement::Name(name) = replacement {
516+
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
517+
name.to_string(),
518+
attr.range(),
519+
)));
520+
}
521+
checker.report_diagnostic(diagnostic);
514522
}
515523

516524
/// Check whether a removed Airflow name is used.

0 commit comments

Comments
 (0)