Skip to content

Commit 2414829

Browse files
Lee-Wsecond-ed
authored andcommitted
[airflow] Convert DatasetOrTimeSchedule(datasets=...) to AssetOrTimeSchedule(assets=...) (AIR311) (astral-sh#20202)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> update the argument `datasets` as `assets` ## Test Plan <!-- How was it tested? --> update fixture accordingly
1 parent 3250f2e commit 2414829

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
from airflow.utils.dag_parsing_context import get_parsing_context
7171

7272
# airflow.timetables.datasets
73-
DatasetOrTimeSchedule()
73+
DatasetOrTimeSchedule(datasets=[])
7474

7575
# airflow.utils.dag_parsing_context
7676
get_parsing_context()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ fn check_call_arguments(checker: &Checker, qualified_name: &QualifiedName, argum
157157
["airflow", .., "DAG" | "dag"] => {
158158
diagnostic_for_argument(checker, arguments, "sla_miss_callback", None);
159159
}
160+
["airflow", "timetables", "datasets", "DatasetOrTimeSchedule"] => {
161+
diagnostic_for_argument(checker, arguments, "datasets", Some("assets"));
162+
}
160163
segments => {
161164
if is_airflow_builtin_or_provider(segments, "operators", "Operator") {
162165
diagnostic_for_argument(checker, arguments, "sla", None);

crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_names.py.snap

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSchedule` is removed in Air
558558
--> AIR311_names.py:73:1
559559
|
560560
72 | # airflow.timetables.datasets
561-
73 | DatasetOrTimeSchedule()
561+
73 | DatasetOrTimeSchedule(datasets=[])
562562
| ^^^^^^^^^^^^^^^^^^^^^
563563
74 |
564564
75 | # airflow.utils.dag_parsing_context
@@ -570,12 +570,31 @@ help: Use `AssetOrTimeSchedule` from `airflow.timetables.assets` instead.
570570
71 + from airflow.timetables.assets import AssetOrTimeSchedule
571571
72 |
572572
73 | # airflow.timetables.datasets
573-
- DatasetOrTimeSchedule()
574-
74 + AssetOrTimeSchedule()
573+
- DatasetOrTimeSchedule(datasets=[])
574+
74 + AssetOrTimeSchedule(datasets=[])
575575
75 |
576576
76 | # airflow.utils.dag_parsing_context
577577
77 | get_parsing_context()
578578

579+
AIR311 [*] `datasets` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
580+
--> AIR311_names.py:73:23
581+
|
582+
72 | # airflow.timetables.datasets
583+
73 | DatasetOrTimeSchedule(datasets=[])
584+
| ^^^^^^^^
585+
74 |
586+
75 | # airflow.utils.dag_parsing_context
587+
|
588+
help: Use `assets` instead
589+
70 | from airflow.utils.dag_parsing_context import get_parsing_context
590+
71 |
591+
72 | # airflow.timetables.datasets
592+
- DatasetOrTimeSchedule(datasets=[])
593+
73 + DatasetOrTimeSchedule(assets=[])
594+
74 |
595+
75 | # airflow.utils.dag_parsing_context
596+
76 | get_parsing_context()
597+
579598
AIR311 [*] `airflow.utils.dag_parsing_context.get_parsing_context` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
580599
--> AIR311_names.py:76:1
581600
|
@@ -593,7 +612,7 @@ help: Use `get_parsing_context` from `airflow.sdk` instead.
593612
70 + from airflow.sdk import get_parsing_context
594613
71 |
595614
72 | # airflow.timetables.datasets
596-
73 | DatasetOrTimeSchedule()
615+
73 | DatasetOrTimeSchedule(datasets=[])
597616
note: This is an unsafe fix and may change runtime behavior
598617

599618
AIR311 [*] `airflow.decorators.base.DecoratedMappedOperator` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.

0 commit comments

Comments
 (0)