Skip to content

Commit

Permalink
feat(AIR302-arg): arg "use_task_execution_day" was removed in "DayOfW…
Browse files Browse the repository at this point in the history
…eekSensor", "BranchDateTimeOperator" and "BranchDayOfWeekOperator"
  • Loading branch information
Lee-W committed Dec 4, 2024
1 parent 9d6f75e commit 651c37a
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 38 deletions.
34 changes: 31 additions & 3 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
from airflow.providers.standard.operators import trigger_dagrun

from airflow.operators.datetime import BranchDateTimeOperator
from airflow.providers.standard.operators import datetime

from airflow.sensors.weekday import DayOfWeekSensor, BranchDayOfWeekOperator
from airflow.providers.standard.sensors import weekday

DAG(dag_id="class_schedule", schedule="@hourly")

DAG(dag_id="class_schedule_interval", schedule_interval="@hourly")
Expand Down Expand Up @@ -39,12 +45,34 @@ def decorator_sla_callback():


@dag()
def decorator_trigger_dag_run_operator():
trigger_dagrun_op1 = trigger_dagrun.TriggerDagRunOperator(
def decorator_deprecated_operator_args():
trigger_dagrun_op = trigger_dagrun.TriggerDagRunOperator(
task_id="trigger_dagrun_op1", execution_date="2024-12-04"
)
trigger_dagrun_op2 = TriggerDagRunOperator(
task_id="trigger_dagrun_op2", execution_date="2024-12-04"
)

trigger_dagrun_op1 >> trigger_dagrun_op2
branch_dt_op = datetime.BranchDateTimeOperator(
task_id="branch_dt_op", use_task_execution_day=True
)
branch_dt_op2 = BranchDateTimeOperator(
task_id="branch_dt_op2", use_task_execution_day=True
)

dof_task_sensor = weekday.DayOfWeekSensor(
task_id="dof_task_sensor", use_task_execution_day=True
)
dof_task_sensor2 = DayOfWeekSensor(
task_id="dof_task_sensor2", use_task_execution_day=True
)

bdow_op = weekday.BranchDayOfWeekOperator(
task_id="bdow_op", use_task_execution_day=True
)
bdow_op2 = BranchDayOfWeekOperator(task_id="bdow_op2", use_task_execution_day=True)

trigger_dagrun_op >> trigger_dagrun_op2
branch_dt_op >> branch_dt_op2
dof_task_sensor >> dof_task_sensor2
bdow_op >> bdow_op2
21 changes: 21 additions & 0 deletions crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ fn removed_argument(checker: &mut Checker, qualname: &QualifiedName, arguments:
Some("logical_date"),
));
}
["airflow", .., "operators", "datetime", "BranchDateTimeOperator"] => {
checker.diagnostics.extend(diagnostic_for_argument(
arguments,
"use_task_execution_day",
Some("use_task_logical_date"),
));
}
["airflow", .., "operators", "weekday", "DayOfWeekSensor"] => {
checker.diagnostics.extend(diagnostic_for_argument(
arguments,
"use_task_execution_day",
Some("use_task_logical_date"),
));
}
["airflow", .., "operators", "weekday", "BranchDayOfWeekOperator"] => {
checker.diagnostics.extend(diagnostic_for_argument(
arguments,
"use_task_execution_day",
Some("use_task_logical_date"),
));
}
_ => {}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,87 @@
source: crates/ruff_linter/src/rules/airflow/mod.rs
snapshot_kind: text
---
AIR302_args.py:9:39: AIR302 `schedule_interval` is removed in Airflow 3.0; use `schedule` instead
AIR302_args.py:15:39: AIR302 `schedule_interval` is removed in Airflow 3.0; use `schedule` instead
|
7 | DAG(dag_id="class_schedule", schedule="@hourly")
8 |
9 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly")
13 | DAG(dag_id="class_schedule", schedule="@hourly")
14 |
15 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly")
| ^^^^^^^^^^^^^^^^^ AIR302
10 |
11 | DAG(dag_id="class_timetable", timetable=NullTimetable())
16 |
17 | DAG(dag_id="class_timetable", timetable=NullTimetable())
|

AIR302_args.py:11:31: AIR302 `timetable` is removed in Airflow 3.0; use `schedule` instead
AIR302_args.py:17:31: AIR302 `timetable` is removed in Airflow 3.0; use `schedule` instead
|
9 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly")
10 |
11 | DAG(dag_id="class_timetable", timetable=NullTimetable())
15 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly")
16 |
17 | DAG(dag_id="class_timetable", timetable=NullTimetable())
| ^^^^^^^^^ AIR302
|

AIR302_args.py:18:34: AIR302 `sla_miss_callback` is removed in Airflow 3.0
AIR302_args.py:24:34: AIR302 `sla_miss_callback` is removed in Airflow 3.0
|
18 | DAG(dag_id="class_sla_callback", sla_miss_callback=sla_callback)
24 | DAG(dag_id="class_sla_callback", sla_miss_callback=sla_callback)
| ^^^^^^^^^^^^^^^^^ AIR302
|

AIR302_args.py:26:6: AIR302 `schedule_interval` is removed in Airflow 3.0; use `schedule` instead
AIR302_args.py:32:6: AIR302 `schedule_interval` is removed in Airflow 3.0; use `schedule` instead
|
26 | @dag(schedule_interval="0 * * * *")
32 | @dag(schedule_interval="0 * * * *")
| ^^^^^^^^^^^^^^^^^ AIR302
27 | def decorator_schedule_interval():
28 | pass
33 | def decorator_schedule_interval():
34 | pass
|

AIR302_args.py:31:6: AIR302 `timetable` is removed in Airflow 3.0; use `schedule` instead
AIR302_args.py:37:6: AIR302 `timetable` is removed in Airflow 3.0; use `schedule` instead
|
31 | @dag(timetable=NullTimetable())
37 | @dag(timetable=NullTimetable())
| ^^^^^^^^^ AIR302
32 | def decorator_timetable():
33 | pass
38 | def decorator_timetable():
39 | pass
|

AIR302_args.py:36:6: AIR302 `sla_miss_callback` is removed in Airflow 3.0
AIR302_args.py:42:6: AIR302 `sla_miss_callback` is removed in Airflow 3.0
|
36 | @dag(sla_miss_callback=sla_callback)
42 | @dag(sla_miss_callback=sla_callback)
| ^^^^^^^^^^^^^^^^^ AIR302
37 | def decorator_sla_callback():
38 | pass
43 | def decorator_sla_callback():
44 | pass
|

AIR302_args.py:44:39: AIR302 `execution_date` is removed in Airflow 3.0; use `logical_date` instead
AIR302_args.py:50:39: AIR302 `execution_date` is removed in Airflow 3.0; use `logical_date` instead
|
42 | def decorator_trigger_dag_run_operator():
43 | trigger_dagrun_op1 = trigger_dagrun.TriggerDagRunOperator(
44 | task_id="trigger_dagrun_op1", execution_date="2024-12-04"
48 | def decorator_deprecated_operator_args():
49 | trigger_dagrun_op = trigger_dagrun.TriggerDagRunOperator(
50 | task_id="trigger_dagrun_op1", execution_date="2024-12-04"
| ^^^^^^^^^^^^^^ AIR302
45 | )
46 | trigger_dagrun_op2 = TriggerDagRunOperator(
51 | )
52 | trigger_dagrun_op2 = TriggerDagRunOperator(
|

AIR302_args.py:47:39: AIR302 `execution_date` is removed in Airflow 3.0; use `logical_date` instead
AIR302_args.py:53:39: AIR302 `execution_date` is removed in Airflow 3.0; use `logical_date` instead
|
45 | )
46 | trigger_dagrun_op2 = TriggerDagRunOperator(
47 | task_id="trigger_dagrun_op2", execution_date="2024-12-04"
51 | )
52 | trigger_dagrun_op2 = TriggerDagRunOperator(
53 | task_id="trigger_dagrun_op2", execution_date="2024-12-04"
| ^^^^^^^^^^^^^^ AIR302
48 | )
54 | )
|

AIR302_args.py:57:33: AIR302 `use_task_execution_day` is removed in Airflow 3.0; use `use_task_logical_date` instead
|
56 | branch_dt_op = datetime.BranchDateTimeOperator(
57 | task_id="branch_dt_op", use_task_execution_day=True
| ^^^^^^^^^^^^^^^^^^^^^^ AIR302
58 | )
59 | branch_dt_op2 = BranchDateTimeOperator(
|

AIR302_args.py:60:34: AIR302 `use_task_execution_day` is removed in Airflow 3.0; use `use_task_logical_date` instead
|
58 | )
59 | branch_dt_op2 = BranchDateTimeOperator(
60 | task_id="branch_dt_op2", use_task_execution_day=True
| ^^^^^^^^^^^^^^^^^^^^^^ AIR302
61 | )
|

0 comments on commit 651c37a

Please sign in to comment.