ruff/crates/ruff_linter/resources/test/fixtures/airflow/AIR001.py
Dhruv Manilawala 575deb5d4d
Check AIR001 from builtin or providers operators module (#14631)
## Summary

This PR makes changes to the `AIR001` rule as per
https://github.com/astral-sh/ruff/pull/14627#discussion_r1860212307.

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.
2024-12-04 13:30:47 +05:30

22 lines
822 B
Python

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)
incorrect_name = PythonOperator(task_id="my_task") # AIR001
my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable)
incorrect_name = AirbyteTriggerSyncOperator(task_id="my_task") # AIR001
my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable)
incorrect_name = AppflowFlowRunOperator(task_id="my_task") # AIR001
# Consider only from the `airflow.operators` (or providers operators) module
from airflow import MyOperator
incorrect_name = MyOperator(task_id="my_task")