mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 18:36:35 +00:00
<!-- 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? --> Add utility functions `generate_import_edit` and `generate_remove_and_runtime_import_edit` to generate the fix needed for the airflow rules. 1. `generate_import_edit` is for the cases where the member name has changed. (e.g., `airflow.datasts.Dataset` to `airflow.sdk.Asset`) It's just extracted from the original logic 2. `generate_remove_and_runtime_import_edit` is for cases where the member name has not changed. (e.g., `airflow.operators.pig_operator.PigOperator` to `airflow.providers.apache.pig.hooks.pig.PigCliHook`) This is newly introduced. As it introduced runtime import, I mark it as an unsafe fix. Under the hook, it tried to find the original import statement, remove it, and add a new import fix --- * rules fix * `airflow.sensors.external_task_sensor.ExternalTaskSensorLink` → `airflow.providers.standard.sensors.external_task.ExternalDagLink` ## Test Plan <!-- How was it tested? --> The existing test fixtures have been updated
78 lines
1.6 KiB
Python
78 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from airflow.operators.bash_operator import BashOperator
|
|
from airflow.operators.dagrun_operator import (
|
|
TriggerDagRunLink,
|
|
TriggerDagRunOperator,
|
|
)
|
|
from airflow.operators.latest_only_operator import LatestOnlyOperator
|
|
from airflow.operators.python_operator import (
|
|
BranchPythonOperator,
|
|
PythonOperator,
|
|
PythonVirtualenvOperator,
|
|
ShortCircuitOperator,
|
|
)
|
|
from airflow.sensors.external_task_sensor import (
|
|
ExternalTaskMarker,
|
|
ExternalTaskSensor,
|
|
)
|
|
|
|
BashOperator()
|
|
|
|
TriggerDagRunLink()
|
|
TriggerDagRunOperator()
|
|
|
|
LatestOnlyOperator()
|
|
|
|
BranchPythonOperator()
|
|
PythonOperator()
|
|
PythonVirtualenvOperator()
|
|
ShortCircuitOperator()
|
|
|
|
ExternalTaskMarker()
|
|
ExternalTaskSensor()
|
|
|
|
|
|
from airflow.hooks.subprocess import SubprocessResult
|
|
|
|
SubprocessResult()
|
|
|
|
from airflow.hooks.subprocess import working_directory
|
|
|
|
working_directory()
|
|
|
|
from airflow.operators.datetime import target_times_as_dates
|
|
|
|
target_times_as_dates()
|
|
|
|
from airflow.operators.trigger_dagrun import TriggerDagRunLink
|
|
|
|
TriggerDagRunLink()
|
|
|
|
from airflow.sensors.external_task import ExternalTaskSensorLink
|
|
|
|
ExternalTaskSensorLink()
|
|
|
|
from airflow.sensors.time_delta import WaitSensor
|
|
|
|
WaitSensor()
|
|
|
|
from airflow.operators.dummy import DummyOperator
|
|
|
|
DummyOperator()
|
|
|
|
from airflow.operators.dummy import EmptyOperator
|
|
|
|
EmptyOperator()
|
|
|
|
from airflow.operators.dummy_operator import DummyOperator
|
|
|
|
DummyOperator()
|
|
|
|
from airflow.operators.dummy_operator import EmptyOperator
|
|
|
|
EmptyOperator()
|
|
|
|
from airflow.sensors.external_task_sensor import ExternalTaskSensorLink
|
|
|
|
ExternalTaskSensorLink()
|