Skip to content

Commit

Permalink
feat(AIR303): extend the following rules
Browse files Browse the repository at this point in the history
* apache-airflow-providers-common-sql >= 1.0.0
	* `airflow.hooks.dbapi.ConnectorProtocol` → `airflow.providers.common.sql.hooks.sql.ConnectorProtocol`
	* `airflow.hooks.dbapi.DbApiHook` → `airflow.providers.common.sql.hooks.sql.DbApiHook`
* apache-airflow-providers-cncf-kubernetes >= 7.4.0
	* `airflow.executors.kubernetes_executor_types.ALL_NAMESPACES` → `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types.ALL_NAMESPACES`
	* `airflow.executors.kubernetes_executor_types.POD_EXECUTOR_DONE_KEY` → `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types.POD_EXECUTOR_DONE_KEY`
* apache-airflow-providers-celery == 3.3.0
	* `airflow.executors.celery_executor.app` → `airflow.providers.celery.executors.celery_executor_utils.app`
	* `airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG` → `airflow.providers.celery.executors.default_celery.DEFAULT_CELERY_CONFIG`
* apache-airflow-providers-apache-hive == 1.0.0
	* `airflow.hooks.hive_hooks.HIVE_QUEUE_PRIORITIES` → `airflow.providers.apache.hive.hooks.hive.HIVE_QUEUE_PRIORITIES`
* apache-airflow-providers-apache-hive == 5.1.0
	* `airflow.macros.hive.closest_ds_partition` → `airflow.providers.apache.hive.macros.hive.closest_ds_partition`
	* `airflow.macros.hive.max_partition` → `airflow.providers.apache.hive.macros.hive.max_partition`
  • Loading branch information
Lee-W committed Dec 27, 2024
1 parent d7b7471 commit 61900c2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
30 changes: 27 additions & 3 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR303.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,41 @@
from airflow.auth.managers.fab.api.auth.backend import (
kerberos_auth as backend_kerberos_auth,
)
from airflow.config_templates.default_celery import DEFAULT_CELERY_CONFIG
from airflow.auth.managers.fab.fab_auth_manager import FabAuthManager
from airflow.auth.managers.fab.security_manager import override as fab_override
from airflow.config_templates.default_celery import DEFAULT_CELERY_CONFIG
from airflow.executors.celery_executor import app
from airflow.executors.kubernetes_executor_types import (
ALL_NAMESPACES,
POD_EXECUTOR_DONE_KEY,
)
from airflow.hooks.dbapi import ConnectorProtocol, DbApiHook
from airflow.hooks.hive_hooks import HIVE_QUEUE_PRIORITIES
from airflow.macros.hive import closest_ds_partition, max_partition
from airflow.www.security import FabAirflowSecurityManagerOverride

# apache-airflow-providers-fab
basic_auth, kerberos_auth
auth_current_user
backend_kerberos_auth
fab_override

FabAuthManager
FabAirflowSecurityManagerOverride
FabAuthManager()
FabAirflowSecurityManagerOverride()

# apache-airflow-providers-celery
DEFAULT_CELERY_CONFIG
app

# apache-airflow-providers-common-sql
ConnectorProtocol()
DbApiHook()

# apache-airflow-providers-cncf-kubernetes
ALL_NAMESPACES
POD_EXECUTOR_DONE_KEY

# apache-airflow-providers-apache-hive
HIVE_QUEUE_PRIORITIES
closest_ds_partition()
max_partition()
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ fn moved_to_provider(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) {
version: "3.3.0"
},
)),

["airflow", "executors", "celery_executor", "app"] => Some((
qualname.to_string(),
Replacement::ImportPathMoved{
original_path: "airflow.executors.celery_executor.app",
new_path: "airflow.providers.celery.executors.celery_executor_utils.app",
provider: "celery",
version: "3.3.0"
},
)),
// apache-airflow-providers-common-sql
["airflow", "hooks", "dbapi", "ConnectorProtocol"] => Some((
qualname.to_string(),
Expand Down

0 comments on commit 61900c2

Please sign in to comment.