Skip to content

Commit b41d69b

Browse files
committed
fix(AIR301): update rules based on the latest Airflow 3.0 implementation
* Update the following rules * class attribute * `airflow..sensors.weekday.DayOfWeekSensor` * `use_task_execution_day` removed * `airflow.providers.amazon.aws.auth_manager.aws_auth_manager.AwsAuthManager` * `is_authorized_dataset` * Add the following rules * name * `airflow.auth.managers.base_auth_manager.BaseAuthManager` → `airflow.api_fastapi.auth.managers.base_auth_manager.BaseAuthManager`
1 parent 35f0ce8 commit b41d69b

File tree

5 files changed

+210
-167
lines changed

5 files changed

+210
-167
lines changed

crates/ruff_linter/resources/test/fixtures/airflow/AIR301_args.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from airflow.providers.google.cloud.log.gcs_task_handler import GCSTaskHandler
1313
from airflow.providers.standard.operators import datetime, trigger_dagrun
1414
from airflow.providers.standard.sensors import weekday
15-
from airflow.sensors.weekday import BranchDayOfWeekOperator, DayOfWeekSensor
15+
from airflow.operators.weekday import BranchDayOfWeekOperator
16+
from airflow.sensors.weekday import DayOfWeekSensor
1617
from airflow.timetables.simple import NullTimetable
1718

1819
DAG(dag_id="class_schedule", schedule="@hourly")
@@ -90,3 +91,4 @@ def decorator_deprecated_operator_args():
9091
GCSTaskHandler(filename_template="/tmp/test")
9192

9293
FabAuthManager(None)
94+

crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,7 @@
163163
# airflow.notifications.basenotifier
164164
from airflow.notifications.basenotifier import BaseNotifier
165165
BaseNotifier()
166+
167+
# airflow.auth.manager
168+
from airflow.auth.managers.base_auth_manager import BaseAuthManager
169+
BaseAuthManager()

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ fn check_call_arguments(checker: &Checker, qualified_name: &QualifiedName, argum
244244
));
245245
}
246246
["airflow", .., "operators", "datetime", "BranchDateTimeOperator"]
247-
| ["airflow", .., "operators", "weekday", "DayOfWeekSensor" | "BranchDayOfWeekOperator"] =>
248-
{
247+
| ["airflow", .., "operators", "weekday", "BranchDayOfWeekOperator"]
248+
| ["airflow", .., "sensors", "weekday", "DayOfWeekSensor"] => {
249249
checker.report_diagnostics(diagnostic_for_argument(
250250
arguments,
251251
"use_task_execution_day",
@@ -581,6 +581,12 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
581581
}
582582

583583
// airflow.auth.managers
584+
["airflow", "auth", "managers", "base_auth_manager", "BaseAuthManager"] => {
585+
Replacement::AutoImport {
586+
module: "airflow.api_fastapi.auth.managers.base_auth_manager",
587+
name: "BaseAuthManager",
588+
}
589+
}
584590
["airflow", "auth", "managers", "models", "resource_details", "DatasetDetails"] => {
585591
Replacement::AutoImport {
586592
module: "airflow.api_fastapi.auth.managers.models.resource_details",
@@ -633,7 +639,6 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
633639
},
634640

635641
// airflow.listeners.spec
636-
// TODO: this is removed
637642
["airflow", "listeners", "spec", "dataset", rest] => match *rest {
638643
"on_dataset_created" => Replacement::AutoImport {
639644
module: "airflow.listeners.spec.asset",

0 commit comments

Comments
 (0)