From 3b913ce6524ed3ccd30d9d8fe3763737fc819e69 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 3 Sep 2025 21:22:56 +0800 Subject: [PATCH] [`airflow`] Improve the `AIR002` error message (#20173) ## Summary ### What Change the message from "DAG should have an explicit `schedule` argument" to "`DAG` or `@dag` should have an explicit `schedule` argument" ### Why We're trying to get rid of the idea that DAG in airflow was Directed acyclic graph. Thus, change it to refer to the class `DAG` or the decorator `@dag` might help a bit. ## Test Plan update the test fixtures accordly --- .../src/rules/airflow/rules/dag_schedule_argument.rs | 2 +- .../ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ruff_linter/src/rules/airflow/rules/dag_schedule_argument.rs b/crates/ruff_linter/src/rules/airflow/rules/dag_schedule_argument.rs index c89071f120..efb7a69f13 100644 --- a/crates/ruff_linter/src/rules/airflow/rules/dag_schedule_argument.rs +++ b/crates/ruff_linter/src/rules/airflow/rules/dag_schedule_argument.rs @@ -46,7 +46,7 @@ pub(crate) struct AirflowDagNoScheduleArgument; impl Violation for AirflowDagNoScheduleArgument { #[derive_message_formats] fn message(&self) -> String { - "DAG should have an explicit `schedule` argument".to_string() + "`DAG` or `@dag` should have an explicit `schedule` argument".to_string() } } diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap index 2ca71e8bfa..9b13f0b310 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR002 DAG should have an explicit `schedule` argument +AIR002 `DAG` or `@dag` should have an explicit `schedule` argument --> AIR002.py:4:1 | 2 | from airflow.timetables.simple import NullTimetable @@ -12,7 +12,7 @@ AIR002 DAG should have an explicit `schedule` argument 6 | DAG(dag_id="class_schedule", schedule="@hourly") | -AIR002 DAG should have an explicit `schedule` argument +AIR002 `DAG` or `@dag` should have an explicit `schedule` argument --> AIR002.py:13:2 | 13 | @dag()