Skip to content

Commit

Permalink
feat(AIR302-name): multiple operators was removed from airflow.operators
Browse files Browse the repository at this point in the history
* `airflow.operators.bash_operator.BashOperator` → `airflow.operators.bash.BashOperator`
* `airflow.operators.branch_operator.BaseBranchOperator` → `airflow.operators.branch.BaseBranchOperator`
* `airflow.operators.dummy.EmptyOperator` → `airflow.operators.empty.EmptyOperator`
* `airflow.operators.dummy.DummyOperator` → `airflow.operators.empty.EmptyOperator`
* `airflow.operators.dummy_operator.EmptyOperator` → `airflow.operators.empty.EmptyOperator`
* `airflow.operators.dummy_operator.DummyOperator` → `airflow.operators.empty.EmptyOperator`
* `airflow.operators.email_operator.EmailOperator` → `airflow.operators.email.EmailOperator`
* `airflow.sensors.base_sensor_operator.BaseSensorOperator` → `airflow.sensors.base.BaseSensorOperator`
* `airflow.sensors.date_time_sensor.DateTimeSensor` → `airflow.sensors.date_time.DateTimeSensor`
* `airflow.sensors.external_task.ExternalTaskSensorLink` → `airflow.sensors.external_task.ExternalDagLin`
* `airflow.sensors.external_task_sensor.ExternalTaskMarker` → `airflow.sensors.external_task.ExternalTaskMarker`
* `airflow.sensors.external_task_sensor.ExternalTaskSensor` → `airflow.sensors.external_task.ExternalTaskSensor`
* `airflow.sensors.external_task_sensor.ExternalTaskSensorLink` → `airflow.sensors.external_task.ExternalTaskSensorLink`
* `airflow.sensors.time_delta_sensor.TimeDeltaSensor` → `airflow.sensors.time_delta.TimeDeltaSensor`
  • Loading branch information
Lee-W committed Dec 6, 2024
1 parent e9a2a55 commit 2fdd02e
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 187 deletions.
27 changes: 27 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
from airflow.metrics.validators import AllowListValidator
from airflow.metrics.validators import BlockListValidator
from airflow.operators.subdag import SubDagOperator
from airflow.sensors.external_task import ExternalTaskSensorLink
from airflow.operators.bash_operator import BashOperator
from airflow.operators.branch_operator import BaseBranchOperator
from airflow.operators.dummy import EmptyOperator, DummyOperator
from airflow.operators import dummy_operator
from airflow.operators.email_operator import EmailOperator
from airflow.sensors.base_sensor_operator import BaseSensorOperator
from airflow.sensors.date_time_sensor import DateTimeSensor
from airflow.sensors.external_task_sensor import (
ExternalTaskMarker,
ExternalTaskSensor,
ExternalTaskSensorLink,
)
from airflow.sensors.time_delta_sensor import TimeDeltaSensor
from airflow.secrets.local_filesystem import get_connection, load_connections
from airflow.utils import dates
from airflow.utils.dates import (
Expand Down Expand Up @@ -62,6 +76,19 @@

get_connection, load_connections


ExternalTaskSensorLink
BashOperator
BaseBranchOperator
EmptyOperator, DummyOperator
dummy_operator.EmptyOperator
dummy_operator.DummyOperator
EmailOperator
BaseSensorOperator
DateTimeSensor
(ExternalTaskMarker, ExternalTaskSensor, ExternalTaskSensorLink)
TimeDeltaSensor

TemporaryDirectory
mkdirs

Expand Down
62 changes: 62 additions & 0 deletions crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,68 @@ fn removed_name(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) {
["airflow", "operators", "subdag", ..] => {
Some((qualname.to_string(), Replacement::None))
}
["airflow.sensors.external_task.ExternalTaskSensorLink"] => Some((
qualname.to_string(),
Replacement::Name("airflow.sensors.external_task.ExternalDagLin".to_string()),
)),
["airflow", "operators", "bash_operator", "BashOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.bash.BashOperator".to_string()),
)),
["airflow", "operators", "branch_operator", "BaseBranchOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.branch.BaseBranchOperator".to_string()),
)),
["airflow", "operators", " dummy", "EmptyOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.empty.EmptyOperator".to_string()),
)),
["airflow", "operators", "dummy", "DummyOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.empty.EmptyOperator".to_string()),
)),
["airflow", "operators", "dummy_operator", "EmptyOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.empty.EmptyOperator".to_string()),
)),
["airflow", "operators", "dummy_operator", "DummyOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.empty.EmptyOperator".to_string()),
)),
["airflow", "operators", "email_operator", "EmailOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.operators.email.EmailOperator".to_string()),
)),
["airflow", "sensors", "base_sensor_operator", "BaseSensorOperator"] => Some((
qualname.to_string(),
Replacement::Name("airflow.sensors.base.BaseSensorOperator".to_string()),
)),
["airflow", "sensors", "date_time_sensor", "DateTimeSensor"] => Some((
qualname.to_string(),
Replacement::Name("airflow.sensors.date_time.DateTimeSensor".to_string()),
)),
["airflow", "sensors", "external_task_sensor", "ExternalTaskMarker"] => Some((
qualname.to_string(),
Replacement::Name(
"airflow.sensors.external_task.ExternalTaskMarker".to_string(),
),
)),
["airflow", "sensors", "external_task_sensor", "ExternalTaskSensor"] => Some((
qualname.to_string(),
Replacement::Name(
"airflow.sensors.external_task.ExternalTaskSensor".to_string(),
),
)),
["airflow", "sensors", "external_task_sensor", "ExternalTaskSensorLink"] => Some((
qualname.to_string(),
Replacement::Name(
"airflow.sensors.external_task.ExternalTaskSensorLink".to_string(),
),
)),
["airflow", "sensors", "time_delta_sensor", "TimeDeltaSensor"] => Some((
qualname.to_string(),
Replacement::Name("airflow.sensors.time_delta.TimeDeltaSensor".to_string()),
)),
// airflow.secrets
["airflow", "secrets", "local_filesystem", "load_connections"] => Some((
qualname.to_string(),
Expand Down
Loading

0 comments on commit 2fdd02e

Please sign in to comment.