-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary This PR makes changes to the `AIR001` rule as per #14627 (comment). Additionally, * Avoid returning the `Diagnostic` and update the checker in the rule logic for consistency * Remove test case for different keyword position (I don't think it's required here) ## Test Plan Add test cases for multiple operators from various modules.
- Loading branch information
1 parent
edce559
commit 575deb5
Showing
4 changed files
with
69 additions
and
38 deletions.
There are no files selected for viewing
16 changes: 11 additions & 5 deletions
16
crates/ruff_linter/resources/test/fixtures/airflow/AIR001.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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
from airflow.operators import PythonOperator | ||
from airflow.providers.airbyte.operators.airbyte import AirbyteTriggerSyncOperator | ||
from airflow.providers.amazon.aws.operators.appflow import AppflowFlowRunOperator | ||
|
||
|
||
def my_callable(): | ||
pass | ||
|
||
|
||
my_task = PythonOperator(task_id="my_task", callable=my_callable) | ||
my_task_2 = PythonOperator(callable=my_callable, task_id="my_task_2") | ||
incorrect_name = PythonOperator(task_id="my_task") # AIR001 | ||
|
||
incorrect_name = PythonOperator(task_id="my_task") | ||
incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") | ||
my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) | ||
incorrect_name = AirbyteTriggerSyncOperator(task_id="my_task") # AIR001 | ||
|
||
from my_module import MyClass | ||
my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) | ||
incorrect_name = AppflowFlowRunOperator(task_id="my_task") # AIR001 | ||
|
||
incorrect_name = MyClass(task_id="my_task") | ||
# Consider only from the `airflow.operators` (or providers operators) module | ||
from airflow import MyOperator | ||
|
||
incorrect_name = MyOperator(task_id="my_task") |
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
30 changes: 19 additions & 11 deletions
30
...ter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/airflow/mod.rs | ||
snapshot_kind: text | ||
--- | ||
AIR001.py:11:1: AIR001 Task variable name should match the `task_id`: "my_task" | ||
| | ||
9 | my_task_2 = PythonOperator(callable=my_callable, task_id="my_task_2") | ||
10 | | ||
11 | incorrect_name = PythonOperator(task_id="my_task") | ||
10 | my_task = PythonOperator(task_id="my_task", callable=my_callable) | ||
11 | incorrect_name = PythonOperator(task_id="my_task") # AIR001 | ||
| ^^^^^^^^^^^^^^ AIR001 | ||
12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") | ||
12 | | ||
13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) | ||
| | ||
|
||
AIR001.py:12:1: AIR001 Task variable name should match the `task_id`: "my_task_2" | ||
AIR001.py:14:1: AIR001 Task variable name should match the `task_id`: "my_task" | ||
| | ||
11 | incorrect_name = PythonOperator(task_id="my_task") | ||
12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") | ||
| ^^^^^^^^^^^^^^^^ AIR001 | ||
13 | | ||
14 | from my_module import MyClass | ||
13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) | ||
14 | incorrect_name = AirbyteTriggerSyncOperator(task_id="my_task") # AIR001 | ||
| ^^^^^^^^^^^^^^ AIR001 | ||
15 | | ||
16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) | ||
| | ||
|
||
AIR001.py:17:1: AIR001 Task variable name should match the `task_id`: "my_task" | ||
| | ||
16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) | ||
17 | incorrect_name = AppflowFlowRunOperator(task_id="my_task") # AIR001 | ||
| ^^^^^^^^^^^^^^ AIR001 | ||
18 | | ||
19 | # Consider only from the `airflow.operators` (or providers operators) module | ||
| |