Skip to content

[airflow] Apply auto fixes to cases where the names have changed in Airflow 3 (AIR302) #17553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 28, 2025
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
481 changes: 0 additions & 481 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import annotations

from airflow.hooks.S3_hook import (
S3Hook,
provide_bucket_name,
)
from airflow.operators.gcs_to_s3 import GCSToS3Operator
from airflow.operators.google_api_to_s3_transfer import (
GoogleApiToS3Operator,
GoogleApiToS3Transfer,
)
from airflow.operators.redshift_to_s3_operator import (
RedshiftToS3Operator,
RedshiftToS3Transfer,
)
from airflow.operators.s3_file_transform_operator import S3FileTransformOperator
from airflow.operators.s3_to_redshift_operator import (
S3ToRedshiftOperator,
S3ToRedshiftTransfer,
)
from airflow.sensors.s3_key_sensor import S3KeySensor

S3Hook()
provide_bucket_name()

GCSToS3Operator()

GoogleApiToS3Operator()
GoogleApiToS3Transfer()

RedshiftToS3Operator()
RedshiftToS3Transfer()

S3FileTransformOperator()

S3ToRedshiftOperator()
S3ToRedshiftTransfer()

S3KeySensor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

from airflow.config_templates.default_celery import DEFAULT_CELERY_CONFIG
from airflow.executors.celery_executor import (
CeleryExecutor,
app,
)

DEFAULT_CELERY_CONFIG

app
CeleryExecutor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
from __future__ import annotations

from airflow.hooks.dbapi import (
ConnectorProtocol,
DbApiHook,
)
from airflow.hooks.dbapi_hook import DbApiHook
from airflow.operators.check_operator import SQLCheckOperator

ConnectorProtocol()
DbApiHook()
SQLCheckOperator()


from airflow.operators.check_operator import CheckOperator
from airflow.operators.sql import SQLCheckOperator

SQLCheckOperator()
CheckOperator()


from airflow.operators.druid_check_operator import CheckOperator

CheckOperator()


from airflow.operators.presto_check_operator import CheckOperator

CheckOperator()


from airflow.operators.check_operator import (
IntervalCheckOperator,
SQLIntervalCheckOperator,
)
from airflow.operators.druid_check_operator import DruidCheckOperator
from airflow.operators.presto_check_operator import PrestoCheckOperator

DruidCheckOperator()
PrestoCheckOperator()
IntervalCheckOperator()
SQLIntervalCheckOperator()


from airflow.operators.presto_check_operator import (
IntervalCheckOperator,
PrestoIntervalCheckOperator,
)
from airflow.operators.sql import SQLIntervalCheckOperator

IntervalCheckOperator()
SQLIntervalCheckOperator()
PrestoIntervalCheckOperator()


from airflow.operators.check_operator import (
SQLThresholdCheckOperator,
ThresholdCheckOperator,
)

SQLThresholdCheckOperator()
ThresholdCheckOperator()


from airflow.operators.sql import SQLThresholdCheckOperator

SQLThresholdCheckOperator()


from airflow.operators.check_operator import (
SQLValueCheckOperator,
ValueCheckOperator,
)

SQLValueCheckOperator()
ValueCheckOperator()


from airflow.operators.presto_check_operator import (
PrestoValueCheckOperator,
ValueCheckOperator,
)
from airflow.operators.sql import SQLValueCheckOperator

SQLValueCheckOperator()
ValueCheckOperator()
PrestoValueCheckOperator()


from airflow.operators.sql import (
BaseSQLOperator,
BranchSQLOperator,
SQLColumnCheckOperator,
SQLTablecheckOperator,
_convert_to_float_if_possible,
parse_boolean,
)

BaseSQLOperator()
BranchSQLOperator()
SQLTablecheckOperator()
SQLColumnCheckOperator()
_convert_to_float_if_possible()
parse_boolean()


from airflow.sensors.sql import SqlSensor

SqlSensor()


from airflow.sensors.sql_sensor import SqlSensor

SqlSensor()


from airflow.operators.jdbc_operator import JdbcOperator
from airflow.operators.mssql_operator import MsSqlOperator
from airflow.operators.mysql_operator import MySqlOperator
from airflow.operators.oracle_operator import OracleOperator
from airflow.operators.postgres_operator import PostgresOperator
from airflow.operators.sqlite_operator import SqliteOperator

JdbcOperator()
MsSqlOperator()
MySqlOperator()
OracleOperator()
PostgresOperator()
SqliteOperator()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from airflow.executors.dask_executor import DaskExecutor

DaskExecutor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

from airflow.hooks.docker_hook import DockerHook
from airflow.operators.docker_operator import DockerOperator

DockerHook()
DockerOperator()
16 changes: 16 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302_druid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import annotations

from airflow.hooks.druid_hook import (
DruidDbApiHook,
DruidHook,
)
from airflow.operators.hive_to_druid import (
HiveToDruidOperator,
HiveToDruidTransfer,
)

DruidDbApiHook()
DruidHook()

HiveToDruidOperator()
HiveToDruidTransfer()
55 changes: 55 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302_fab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from __future__ import annotations

from airflow.api.auth.backend.basic_auth import (
CLIENT_AUTH,
auth_current_user,
init_app,
requires_authentication,
)

CLIENT_AUTH
init_app()
auth_current_user()
requires_authentication()

from airflow.api.auth.backend.kerberos_auth import (
CLIENT_AUTH,
find_user,
init_app,
log,
requires_authentication,
)

log()
CLIENT_AUTH
find_user()
init_app()
requires_authentication()

from airflow.auth.managers.fab.api.auth.backend.kerberos_auth import (
CLIENT_AUTH,
find_user,
init_app,
log,
requires_authentication,
)

log()
CLIENT_AUTH
find_user()
init_app()
requires_authentication()

from airflow.auth.managers.fab.fab_auth_manager import FabAuthManager
from airflow.auth.managers.fab.security_manager.override import (
MAX_NUM_DATABASE_USER_SESSIONS,
FabAirflowSecurityManagerOverride,
)

FabAuthManager()
MAX_NUM_DATABASE_USER_SESSIONS
FabAirflowSecurityManagerOverride()

from airflow.www.security import FabAirflowSecurityManagerOverride

FabAirflowSecurityManagerOverride()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

from airflow.hooks.webhdfs_hook import WebHDFSHook
from airflow.sensors.web_hdfs_sensor import WebHdfsSensor

WebHDFSHook()
WebHdfsSensor()
66 changes: 66 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR302_hive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from __future__ import annotations

from airflow.hooks.hive_hooks import (
HIVE_QUEUE_PRIORITIES,
HiveCliHook,
HiveMetastoreHook,
HiveServer2Hook,
)
from airflow.macros.hive import (
closest_ds_partition,
max_partition,
)
from airflow.operators.hive_operator import HiveOperator
from airflow.operators.hive_stats_operator import HiveStatsCollectionOperator
from airflow.operators.hive_to_mysql import (
HiveToMySqlOperator,
HiveToMySqlTransfer,
)
from airflow.operators.hive_to_samba_operator import HiveToSambaOperator
from airflow.operators.mssql_to_hive import (
MsSqlToHiveOperator,
MsSqlToHiveTransfer,
)
from airflow.operators.mysql_to_hive import (
MySqlToHiveOperator,
MySqlToHiveTransfer,
)
from airflow.operators.s3_to_hive_operator import (
S3ToHiveOperator,
S3ToHiveTransfer,
)
from airflow.sensors.hive_partition_sensor import HivePartitionSensor
from airflow.sensors.metastore_partition_sensor import MetastorePartitionSensor
from airflow.sensors.named_hive_partition_sensor import NamedHivePartitionSensor

closest_ds_partition()
max_partition()

HiveCliHook()
HiveMetastoreHook()
HiveServer2Hook()
HIVE_QUEUE_PRIORITIES

HiveOperator()

HiveStatsCollectionOperator()

HiveToMySqlOperator()
HiveToMySqlTransfer()

HiveToSambaOperator()

MsSqlToHiveOperator()
MsSqlToHiveTransfer()

MySqlToHiveOperator()
MySqlToHiveTransfer()

S3ToHiveOperator()
S3ToHiveTransfer()

HivePartitionSensor()

MetastorePartitionSensor()

NamedHivePartitionSensor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations

from airflow.hooks.http_hook import HttpHook
from airflow.operators.http_operator import SimpleHttpOperator
from airflow.sensors.http_sensor import HttpSensor

HttpHook()
SimpleHttpOperator()
HttpSensor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations

from airflow.hooks.jdbc_hook import (
JdbcHook,
jaydebeapi,
)

JdbcHook()
jaydebeapi()
Loading
Loading