Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@
from airflow.listeners.spec.dataset import on_dataset_changed, on_dataset_created
from airflow.metrics.validators import AllowListValidator, BlockListValidator
from airflow.models.baseoperator import chain, chain_linear, cross_downstream
from airflow.models.baseoperatorlink import BaseOperatorLink
from airflow.notifications.basenotifier import BaseNotifier
from airflow.operators import dummy_operator
from airflow.operators.branch_operator import BaseBranchOperator
from airflow.operators.dagrun_operator import TriggerDagRunLink, TriggerDagRunOperator
from airflow.operators.dummy import DummyOperator, EmptyOperator
from airflow.operators.email_operator import EmailOperator
from airflow.operators.latest_only_operator import LatestOnlyOperator
from airflow.operators.python_operator import (
BranchPythonOperator,
PythonOperator,
PythonVirtualenvOperator,
ShortCircuitOperator,
)
from airflow.operators.subdag import SubDagOperator
from airflow.providers.amazon.aws.auth_manager.avp.entities import AvpEntities
from airflow.providers.amazon.aws.datasets import s3
Expand All @@ -75,22 +61,6 @@
from airflow.secrets.local_filesystem import LocalFilesystemBackend, load_connections
from airflow.security.permissions import RESOURCE_DATASET
from airflow.sensors.base_sensor_operator import BaseSensorOperator
from airflow.sensors.date_time_sensor import DateTimeSensor
from airflow.sensors.external_task import (
ExternalTaskMarker,
ExternalTaskSensor,
ExternalTaskSensorLink,
)
from airflow.sensors.external_task_sensor import (
ExternalTaskMarker as ExternalTaskMarkerFromExternalTaskSensor,
)
from airflow.sensors.external_task_sensor import (
ExternalTaskSensor as ExternalTaskSensorFromExternalTaskSensor,
)
from airflow.sensors.external_task_sensor import (
ExternalTaskSensorLink as ExternalTaskSensorLinkFromExternalTaskSensor,
)
from airflow.sensors.time_delta_sensor import TimeDeltaSensor
from airflow.timetables.datasets import DatasetOrTimeSchedule
from airflow.timetables.simple import DatasetTriggeredTimetable
from airflow.triggers.external_task import TaskStateTrigger
Expand Down Expand Up @@ -167,19 +137,6 @@
# airflow.models.baseoperator
chain, chain_linear, cross_downstream

# airflow.models.baseoperatorlink
BaseOperatorLink()

# ariflow.notifications.basenotifier
BaseNotifier()

# airflow.operators.dummy
EmptyOperator()
DummyOperator()

# airflow.operators.dummy_operator
dummy_operator.EmptyOperator()
dummy_operator.DummyOperator()

# airflow.operators.branch_operator
BaseBranchOperator()
Expand Down Expand Up @@ -248,21 +205,6 @@
# airflow.sensors.base_sensor_operator
BaseSensorOperator()

# airflow.sensors.date_time_sensor
DateTimeSensor()

# airflow.sensors.external_task
ExternalTaskSensorLink()
ExternalTaskMarker()
ExternalTaskSensor()

# airflow.sensors.external_task_sensor
ExternalTaskMarkerFromExternalTaskSensor()
ExternalTaskSensorFromExternalTaskSensor()
ExternalTaskSensorLinkFromExternalTaskSensor()

# airflow.sensors.time_delta_sensor
TimeDeltaSensor()

# airflow.timetables
DatasetOrTimeSchedule()
Expand Down
41 changes: 33 additions & 8 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
from airflow.operators.datetime import BranchDateTimeOperator
from airflow.operators.docker_operator import DockerOperator
from airflow.operators.druid_check_operator import DruidCheckOperator
from airflow.operators.dummy import DummyOperator, EmptyOperator
from airflow.operators.email import EmailOperator
from airflow.operators.email_operator import EmailOperator
from airflow.operators.gcs_to_s3 import GCSToS3Operator
from airflow.operators.google_api_to_s3_transfer import (
GoogleApiToS3Operator,
Expand Down Expand Up @@ -153,6 +156,12 @@
PrestoToMySqlOperator,
PrestoToMySqlTransfer,
)
from airflow.operators.python import (
BranchPythonOperator,
PythonOperator,
PythonVirtualenvOperator,
ShortCircuitOperator,
)
from airflow.operators.redshift_to_s3_operator import (
RedshiftToS3Operator,
RedshiftToS3Transfer,
Expand Down Expand Up @@ -190,7 +199,12 @@
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
from airflow.operators.weekday import BranchDayOfWeekOperator
from airflow.sensors.date_time import DateTimeSensor
from airflow.sensors.external_task import ExternalTaskMarker, ExternalTaskSensor
from airflow.sensors.date_time_sensor import DateTimeSensor
from airflow.sensors.external_task import (
ExternalTaskMarker,
ExternalTaskSensor,
ExternalTaskSensorLink,
)
from airflow.sensors.filesystem import FileSensor
from airflow.sensors.hive_partition_sensor import HivePartitionSensor
from airflow.sensors.http_sensor import HttpSensor
Expand Down Expand Up @@ -405,19 +419,30 @@
# apache-airflow-providers-zendesk
ZendeskHook()

# apache-airflow-providers-smtp
EmailOperator()

# apache-airflow-providers-standard
FileSensor()
TriggerDagRunOperator()
ExternalTaskMarker(), ExternalTaskSensor()
BranchDateTimeOperator()
BranchDayOfWeekOperator()
BranchPythonOperator()
DateTimeSensor()
TimeSensor()
TimeDeltaSensor()
DateTimeTrigger()
DayOfWeekSensor()
DummyOperator()
EmptyOperator()
ExternalTaskMarker()
ExternalTaskSensor()
ExternalTaskSensorLink()
FileSensor()
FileTrigger()
FSHook()
PackageIndexHook()
SubprocessHook()
ShortCircuitOperator()
TimeDeltaSensor()
TimeSensor()
TriggerDagRunOperator()
WorkflowTrigger()
FileTrigger()
DateTimeTrigger()
PythonOperator()
PythonVirtualenvOperator()
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
version: "1.0.0"
},
["airflow", "sensors", "s3_key_sensor", "S3KeySensor"] => Replacement::ProviderName{
name: "S3KeySensor",
name: "airflow.providers.amazon.aws.sensors.s3.S3KeySensor",
provider: "amazon",
version: "1.0.0"
},
Expand Down Expand Up @@ -407,7 +407,7 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
name: "airflow.providers.fab.auth_manager.security_manager.override.FabAirflowSecurityManagerOverride",
provider: "fab",
version: "1.0.0"
},
},
["airflow", "auth", "managers", "fab", "fab_auth_manager", "FabAuthManager"] => Replacement::ProviderName{
name: "airflow.providers.fab.auth_manager.security_manager.FabAuthManager",
provider: "fab",
Expand Down Expand Up @@ -873,26 +873,93 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
version: "1.0.0"
},

// apache-airflow-providers-smtp
["airflow", "operators", "email_operator" | "email", "EmailOperator"] => Replacement::ProviderName{
name: "airflow.providers.smtp.operators.smtp.EmailOperator",
provider: "smtp",
version: "1.0.0",
},


// apache-airflow-providers-standard
["airflow", "sensors", "filesystem", "FileSensor"] => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.filesystem.FileSensor",
["airflow", "operators", "bash_operator", "BashOperator"] => Replacement::ProviderName{
name: "airflow.providers.standard.operators.bash.BashOperator",
provider: "standard",
version: "0.0.2"
version: "0.0.1"
},
["airflow", "operators", "trigger_dagrun", "TriggerDagRunOperator"] => Replacement::ProviderName{
name: "airflow.providers.standard.operators.trigger_dagrun.TriggerDagRunOperator",
["airflow", "operators", "dagrun_operator" | "trigger_dagrun", rest] => match *rest {
"TriggerDagRunLink" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.trigger_dagrun.TriggerDagRunLink",
provider: "standard",
version: "0.0.2"
},
"TriggerDagRunOperator" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.trigger_dagrun.TriggerDagRunOperator",
provider: "standard",
version: "0.0.2"
},
_ => return
}
["airflow", "operators", "dummy" | "dummy_operator", "EmptyOperator" | "DummyOperator"] => Replacement::ProviderName{
name: "airflow.providers.standard.operators.empty.EmptyOperator",
provider: "standard",
version: "0.0.2"
},
["airflow", "sensors", "external_task", "ExternalTaskMarker"] => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.external_task.ExternalTaskMarker",
["airflow", "operators", "latest_only_operator" | "latest_only", "LatestOnlyOperator"] => Replacement::ProviderName{
name: "airflow.providers.standard.operators.latest_only.LatestOnlyOperator",
provider: "standard",
version: "0.0.3"
},
["airflow", "sensors", "external_task", "ExternalTaskSensor"] => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.external_task.ExternalTaskSensor",
["airflow", "operators", "python_operator"| "python", rest ] => match *rest {
"BranchPythonOperator" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.python.BranchPythonOperator",
provider: "standard",
version: "0.0.1"
},
"PythonOperator" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.python.PythonOperator",
provider: "standard",
version: "0.0.1"
},
"PythonVirtualenvOperator" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.python.PythonVirtualenvOperator",
provider: "standard",
version: "0.0.1"
},
"ShortCircuitOperator" => Replacement::ProviderName{
name: "airflow.providers.standard.operators.python.ShortCircuitOperator",
provider: "standard",
version: "0.0.1"
},
_ => return
}
["airflow", "sensors", "external_task_sensor" | "external_task", rest] => match *rest {
"ExternalTaskSensor" => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.external_task.ExternalTaskSensor",
provider: "standard",
version: "0.0.3"
},
"ExternalTaskSensorLink" => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.external_task.ExternalTaskSensorLink",
provider: "standard",
version: "0.0.3"
},
"ExternalTaskMarker" => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.external_task.ExternalTaskMarker",
provider: "standard",
version: "0.0.3"
},
_ => return
}
["airflow", "sensors", "filesystem", "FileSensor"] => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.filesystem.FileSensor",
provider: "standard",
version: "0.0.3"
version: "0.0.2"
},
["airflow", "sensors", "time_delta_sensor", "TimeDeltaSensor"] => Replacement::ProviderName{
name: "airflow.providers.standard.sensors.time_delta.TimeDeltaSensor",
provider: "standard",
version: "0.1.0"
},

// apache-airflow-providers-sqlite
Expand Down Expand Up @@ -920,14 +987,14 @@ fn check_names_moved_to_provider(checker: &Checker, expr: &Expr, ranged: TextRan
["airflow", "api", "auth", "backend", "basic_auth", ..] => Replacement::ImportPathMoved{
original_path: "airflow.api.auth.backend.basic_auth",
new_path: "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth",
provider:"fab",
provider: "fab",
version: "1.0.0"
},
["airflow", "api", "auth", "backend", "kerberos_auth", ..] => Replacement::ImportPathMoved{
original_path:"airflow.api.auth.backend.kerberos_auth",
original_path: "airflow.api.auth.backend.kerberos_auth",
new_path: "airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth",
provider: "fab",
version:"1.0.0"
version: "1.0.0"
},
["airflow", "auth", "managers", "fab", "api", "auth", "backend", "kerberos_auth", ..] => Replacement::ImportPathMoved{
original_path: "airflow.auth_manager.api.auth.backend.kerberos_auth",
Expand Down
45 changes: 0 additions & 45 deletions crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,36 +686,6 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
["airflow", "operators", "subdag", ..] => {
Replacement::Message("The whole `airflow.subdag` module has been removed.")
}
["airflow", "operators", "branch_operator", "BaseBranchOperator"] => {
Replacement::Name("airflow.operators.branch.BaseBranchOperator")
}
["airflow", "operators", "dummy" | "dummy_operator", "EmptyOperator" | "DummyOperator"] => {
Replacement::Name("airflow.operators.empty.EmptyOperator")
}
["airflow", "operators", "email_operator", "EmailOperator"] => {
Replacement::Name("airflow.operators.email.EmailOperator")
}
["airflow", "operators", "dagrun_operator", "TriggerDagRunLink"] => {
Replacement::Name("airflow.operators.trigger_dagrun.TriggerDagRunLink")
}
["airflow", "operators", "dagrun_operator", "TriggerDagRunOperator"] => {
Replacement::Name("airflow.operators.trigger_dagrun.TriggerDagRunOperator")
}
["airflow", "operators", "python_operator", "BranchPythonOperator"] => {
Replacement::Name("airflow.operators.python.BranchPythonOperator")
}
["airflow", "operators", "python_operator", "PythonOperator"] => {
Replacement::Name("airflow.operators.python.PythonOperator")
}
["airflow", "operators", "python_operator", "PythonVirtualenvOperator"] => {
Replacement::Name("airflow.operators.python.PythonVirtualenvOperator")
}
["airflow", "operators", "python_operator", "ShortCircuitOperator"] => {
Replacement::Name("airflow.operators.python.ShortCircuitOperator")
}
["airflow", "operators", "latest_only_operator", "LatestOnlyOperator"] => {
Replacement::Name("airflow.operators.latest_only.LatestOnlyOperator")
}

// airflow.secrets
["airflow", "secrets", "local_filesystem", "load_connections"] => {
Expand All @@ -731,21 +701,6 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
["airflow", "sensors", "base_sensor_operator", "BaseSensorOperator"] => {
Replacement::Name("airflow.sdk.bases.sensor.BaseSensorOperator")
}
["airflow", "sensors", "date_time_sensor", "DateTimeSensor"] => {
Replacement::Name("airflow.sensors.date_time.DateTimeSensor")
}
["airflow", "sensors", "external_task" | "external_task_sensor", "ExternalTaskMarker"] => {
Replacement::Name("airflow.sensors.external_task.ExternalTaskMarker")
}
["airflow", "sensors", "external_task" | "external_task_sensor", "ExternalTaskSensorLink"] => {
Replacement::Name("airflow.sensors.external_task.ExternalDagLink")
}
["airflow", "sensors", "external_task" | "external_task_sensor", "ExternalTaskSensor"] => {
Replacement::Name("airflow.sensors.external_task.ExternalTaskSensor")
}
["airflow", "sensors", "time_delta_sensor", "TimeDeltaSensor"] => {
Replacement::Name("airflow.sensors.time_delta.TimeDeltaSensor")
}

// airflow.timetables
["airflow", "timetables", rest @ ..] => match &rest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/airflow/mod.rs
snapshot_kind: text
---
AIR002.py:4:1: AIR002 DAG should have an explicit `schedule` argument
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,6 @@ AIR301_context.py:111:5: AIR301 [*] `schedule_interval` is removed in Airflow 3.
113 113 | template_searchpath=["/templates"],
114 114 | ) as dag:

AIR301_context.py:115:13: AIR301 `airflow.operators.dummy.DummyOperator` is removed in Airflow 3.0
|
113 | template_searchpath=["/templates"],
114 | ) as dag:
115 | task1 = DummyOperator(
| ^^^^^^^^^^^^^ AIR301
116 | task_id="task1",
117 | params={
|
= help: Use `airflow.operators.empty.EmptyOperator` instead

AIR301_context.py:135:23: AIR301 `next_ds` is removed in Airflow 3.0
|
134 | class CustomOperator(BaseOperator):
Expand Down
Loading
Loading