-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lint rule to show error for removed context variables in airflow
- Loading branch information
Showing
5 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
crates/ruff_linter/resources/test/fixtures/airflow/AIR302_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from airflow.decorators import task | ||
|
||
@task | ||
def print_config(**context): | ||
# This should not throw an error as logical_date is part of airflow context. | ||
logical_date = context["logical_date"] | ||
|
||
# Removed usage - should trigger violations | ||
execution_date = context["execution_date"] | ||
next_ds = context["next_ds"] | ||
next_ds_nodash = context["next_ds_nodash"] | ||
next_execution_date = context["next_execution_date"] | ||
prev_ds = context["prev_ds"] | ||
prev_ds_nodash = context["prev_ds_nodash"] | ||
prev_execution_date = context["prev_execution_date"] | ||
prev_execution_date_success = context["prev_execution_date_success"] | ||
tomorrow_ds = context["tomorrow_ds"] | ||
yesterday_ds = context["yesterday_ds"] | ||
yesterday_ds_nodash = context["yesterday_ds_nodash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_context.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/airflow/mod.rs | ||
snapshot_kind: text | ||
--- | ||
AIR302_context.py:9:30: AIR302 `execution_date` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
8 | # Removed usage - should trigger violations | ||
9 | execution_date = context["execution_date"] | ||
| ^^^^^^^^^^^^^^^^ AIR302 | ||
10 | next_ds = context["next_ds"] | ||
11 | next_ds_nodash = context["next_ds_nodash"] | ||
| | ||
|
||
AIR302_context.py:10:23: AIR302 `next_ds` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
8 | # Removed usage - should trigger violations | ||
9 | execution_date = context["execution_date"] | ||
10 | next_ds = context["next_ds"] | ||
| ^^^^^^^^^ AIR302 | ||
11 | next_ds_nodash = context["next_ds_nodash"] | ||
12 | next_execution_date = context["next_execution_date"] | ||
| | ||
|
||
AIR302_context.py:11:30: AIR302 `next_ds_nodash` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
9 | execution_date = context["execution_date"] | ||
10 | next_ds = context["next_ds"] | ||
11 | next_ds_nodash = context["next_ds_nodash"] | ||
| ^^^^^^^^^^^^^^^^ AIR302 | ||
12 | next_execution_date = context["next_execution_date"] | ||
13 | prev_ds = context["prev_ds"] | ||
| | ||
|
||
AIR302_context.py:12:35: AIR302 `next_execution_date` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
10 | next_ds = context["next_ds"] | ||
11 | next_ds_nodash = context["next_ds_nodash"] | ||
12 | next_execution_date = context["next_execution_date"] | ||
| ^^^^^^^^^^^^^^^^^^^^^ AIR302 | ||
13 | prev_ds = context["prev_ds"] | ||
14 | prev_ds_nodash = context["prev_ds_nodash"] | ||
| | ||
|
||
AIR302_context.py:13:23: AIR302 `prev_ds` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
11 | next_ds_nodash = context["next_ds_nodash"] | ||
12 | next_execution_date = context["next_execution_date"] | ||
13 | prev_ds = context["prev_ds"] | ||
| ^^^^^^^^^ AIR302 | ||
14 | prev_ds_nodash = context["prev_ds_nodash"] | ||
15 | prev_execution_date = context["prev_execution_date"] | ||
| | ||
|
||
AIR302_context.py:14:30: AIR302 `prev_ds_nodash` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
12 | next_execution_date = context["next_execution_date"] | ||
13 | prev_ds = context["prev_ds"] | ||
14 | prev_ds_nodash = context["prev_ds_nodash"] | ||
| ^^^^^^^^^^^^^^^^ AIR302 | ||
15 | prev_execution_date = context["prev_execution_date"] | ||
16 | prev_execution_date_success = context["prev_execution_date_success"] | ||
| | ||
|
||
AIR302_context.py:15:35: AIR302 `prev_execution_date` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
13 | prev_ds = context["prev_ds"] | ||
14 | prev_ds_nodash = context["prev_ds_nodash"] | ||
15 | prev_execution_date = context["prev_execution_date"] | ||
| ^^^^^^^^^^^^^^^^^^^^^ AIR302 | ||
16 | prev_execution_date_success = context["prev_execution_date_success"] | ||
17 | tomorrow_ds = context["tomorrow_ds"] | ||
| | ||
|
||
AIR302_context.py:16:43: AIR302 `prev_execution_date_success` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
14 | prev_ds_nodash = context["prev_ds_nodash"] | ||
15 | prev_execution_date = context["prev_execution_date"] | ||
16 | prev_execution_date_success = context["prev_execution_date_success"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 | ||
17 | tomorrow_ds = context["tomorrow_ds"] | ||
18 | yesterday_ds = context["yesterday_ds"] | ||
| | ||
|
||
AIR302_context.py:17:27: AIR302 `tomorrow_ds` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
15 | prev_execution_date = context["prev_execution_date"] | ||
16 | prev_execution_date_success = context["prev_execution_date_success"] | ||
17 | tomorrow_ds = context["tomorrow_ds"] | ||
| ^^^^^^^^^^^^^ AIR302 | ||
18 | yesterday_ds = context["yesterday_ds"] | ||
19 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | ||
| | ||
|
||
AIR302_context.py:18:28: AIR302 `yesterday_ds` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
16 | prev_execution_date_success = context["prev_execution_date_success"] | ||
17 | tomorrow_ds = context["tomorrow_ds"] | ||
18 | yesterday_ds = context["yesterday_ds"] | ||
| ^^^^^^^^^^^^^^ AIR302 | ||
19 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | ||
| | ||
|
||
AIR302_context.py:19:35: AIR302 `yesterday_ds_nodash` is removed in the Airflow context in Airflow 3.0 | ||
| | ||
17 | tomorrow_ds = context["tomorrow_ds"] | ||
18 | yesterday_ds = context["yesterday_ds"] | ||
19 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | ||
| ^^^^^^^^^^^^^^^^^^^^^ AIR302 | ||
| |