Skip to content

Commit 35f0ce8

Browse files
committed
refactor(AIR301): simplify unnecessary match with if else
1 parent dc589cd commit 35f0ce8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,20 @@ fn check_method(checker: &Checker, call_expr: &ExprCall) {
480480
"collected_datasets" => Replacement::AttrName("collected_assets"),
481481
_ => return,
482482
},
483-
["airflow", "providers_manager", "ProvidersManager"] => match attr.as_str() {
484-
"initialize_providers_dataset_uri_resources" => {
483+
["airflow", "providers_manager", "ProvidersManager"] => {
484+
if attr.as_str() == "initialize_providers_dataset_uri_resources" {
485485
Replacement::AttrName("initialize_providers_asset_uri_resources")
486+
} else {
487+
return;
486488
}
487-
_ => return,
488-
},
489-
["airflow", "secrets", "local_filesystem", "LocalFilesystemBackend"] => match attr.as_str()
490-
{
491-
"get_connections" => Replacement::AttrName("get_connection"),
492-
_ => return,
493-
},
489+
}
490+
["airflow", "secrets", "local_filesystem", "LocalFilesystemBackend"] => {
491+
if attr.as_str() == "get_connections" {
492+
Replacement::AttrName("get_connection")
493+
} else {
494+
return;
495+
}
496+
}
494497
["airflow", "datasets", ..] | ["airflow", "Dataset"] => match attr.as_str() {
495498
"iter_datasets" => Replacement::AttrName("iter_assets"),
496499
"iter_dataset_aliases" => Replacement::AttrName("iter_asset_aliases"),
@@ -503,17 +506,14 @@ fn check_method(checker: &Checker, call_expr: &ExprCall) {
503506
"get_connections" => Replacement::AttrName("get_connection"),
504507
_ => return,
505508
}
506-
} else if is_airflow_hook(segments) {
507-
match attr.as_str() {
508-
"get_connections" => Replacement::AttrName("get_connection"),
509-
_ => return,
510-
}
511509
} else if is_airflow_auth_manager(segments) {
512510
if attr.as_str() == "is_authorized_dataset" {
513511
Replacement::AttrName("is_authorized_asset")
514512
} else {
515513
return;
516514
}
515+
} else if is_airflow_hook(segments) && attr.as_str() == "get_connections" {
516+
Replacement::AttrName("get_connection")
517517
} else {
518518
return;
519519
}

0 commit comments

Comments
 (0)