From 5f686601119ab25055a80ad92fddb502730d2d48 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2024 17:08:13 +0900 Subject: [PATCH 1/2] style(AIR303): add spaces to slice --- .../src/rules/airflow/rules/moved_to_provider_in_3.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs b/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs index 84e14c6f1f4a2e..1153f70bbd952f 100644 --- a/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs +++ b/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs @@ -111,7 +111,7 @@ fn moved_to_provider(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) { version: "1.0.0" }, )), - ["airflow","auth","managers","fab","fab_auth_manager", "FabAuthManager"] => Some(( + ["airflow", "auth", "managers", "fab", "fab_auth_manager", "FabAuthManager"] => Some(( qualname.to_string(), Replacement::ProviderName{ name: "airflow.providers.fab.auth_manager.security_manager.FabAuthManager", @@ -128,7 +128,7 @@ fn moved_to_provider(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) { version: "1.0.0" }, )), - ["airflow", "api","auth","backend","kerberos_auth", ..] => Some(( + ["airflow", "api", "auth", "backend", "kerberos_auth", ..] => Some(( qualname.to_string(), Replacement::ImportPathMoved{ original_path:"airflow.api.auth.backend.kerberos_auth", @@ -146,7 +146,7 @@ fn moved_to_provider(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) { version: "1.0.0" }, )), - ["airflow","auth","managers","fab","security_manager","override", ..] => Some(( + ["airflow", "auth", "managers", "fab", "security_manager", "override", ..] => Some(( qualname.to_string(), Replacement::ImportPathMoved{ original_path: "airflow.auth.managers.fab.security_manager.override", From 165de031593bdd30addeddf1accfdaa24fdd6de6 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2024 17:16:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat(AIR303):=20airflow.config=5Ftemplates.?= =?UTF-8?q?default=5Fcelery.DEFAULT=5FCELERY=5FCONFIG=20=E2=86=92=20airflo?= =?UTF-8?q?w.providers.celery.executors.default=5Fcelery.DEFAULT=5FCELERY?= =?UTF-8?q?=5FCONFIG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/test/fixtures/airflow/AIR303.py | 3 + .../airflow/rules/moved_to_provider_in_3.rs | 12 ++- ...les__airflow__tests__AIR303_AIR303.py.snap | 83 +++++++++++-------- 3 files changed, 61 insertions(+), 37 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/airflow/AIR303.py b/crates/ruff_linter/resources/test/fixtures/airflow/AIR303.py index ffd3c47b7f21a8..363ec5dce5514a 100644 --- a/crates/ruff_linter/resources/test/fixtures/airflow/AIR303.py +++ b/crates/ruff_linter/resources/test/fixtures/airflow/AIR303.py @@ -3,6 +3,7 @@ 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.www.security import FabAirflowSecurityManagerOverride @@ -14,3 +15,5 @@ FabAuthManager FabAirflowSecurityManagerOverride + +DEFAULT_CELERY_CONFIG diff --git a/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs b/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs index 1153f70bbd952f..3e075b6dd87047 100644 --- a/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs +++ b/crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs @@ -149,12 +149,22 @@ fn moved_to_provider(checker: &mut Checker, expr: &Expr, ranged: impl Ranged) { ["airflow", "auth", "managers", "fab", "security_manager", "override", ..] => Some(( qualname.to_string(), Replacement::ImportPathMoved{ - original_path: "airflow.auth.managers.fab.security_manager.override", + original_path: "airflow.auth.managers.fab.security_managr.override", new_path: "airflow.providers.fab.auth_manager.security_manager.override", provider: "fab", version: "1.0.0" }, )), + // apache-airflow-providers-celery + ["airflow", "config_templates", "default_celery", "DEFAULT_CELERY_CONFIG"] => Some(( + qualname.to_string(), + Replacement::ImportPathMoved{ + original_path: "airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG", + new_path: "airflow.providers.celery.executors.default_celery.DEFAULT_CELERY_CONFIG", + provider: "celery", + version: "3.3.0" + }, + )), _ => None, }); diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap index d84f5d7f2cb7c9..86586310f6a20d 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR303_AIR303.py.snap @@ -2,73 +2,84 @@ source: crates/ruff_linter/src/rules/airflow/mod.rs snapshot_kind: text --- -AIR303.py:10:1: AIR303 Import path `airflow.api.auth.backend.basic_auth` is moved into `fab` provider in Airflow 3.0; +AIR303.py:11:1: AIR303 Import path `airflow.api.auth.backend.basic_auth` is moved into `fab` provider in Airflow 3.0; | - 8 | from airflow.www.security import FabAirflowSecurityManagerOverride - 9 | -10 | basic_auth, kerberos_auth + 9 | from airflow.www.security import FabAirflowSecurityManagerOverride +10 | +11 | basic_auth, kerberos_auth | ^^^^^^^^^^ AIR303 -11 | auth_current_user -12 | backend_kerberos_auth +12 | auth_current_user +13 | backend_kerberos_auth | = help: Install `apache-airflow-provider-fab>=1.0.0` and import from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. -AIR303.py:10:13: AIR303 Import path `airflow.api.auth.backend.kerberos_auth` is moved into `fab` provider in Airflow 3.0; +AIR303.py:11:13: AIR303 Import path `airflow.api.auth.backend.kerberos_auth` is moved into `fab` provider in Airflow 3.0; | - 8 | from airflow.www.security import FabAirflowSecurityManagerOverride - 9 | -10 | basic_auth, kerberos_auth + 9 | from airflow.www.security import FabAirflowSecurityManagerOverride +10 | +11 | basic_auth, kerberos_auth | ^^^^^^^^^^^^^ AIR303 -11 | auth_current_user -12 | backend_kerberos_auth +12 | auth_current_user +13 | backend_kerberos_auth | = help: Install `apache-airflow-provider-fab>=1.0.0` and import from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. -AIR303.py:11:1: AIR303 Import path `airflow.api.auth.backend.basic_auth` is moved into `fab` provider in Airflow 3.0; +AIR303.py:12:1: AIR303 Import path `airflow.api.auth.backend.basic_auth` is moved into `fab` provider in Airflow 3.0; | -10 | basic_auth, kerberos_auth -11 | auth_current_user +11 | basic_auth, kerberos_auth +12 | auth_current_user | ^^^^^^^^^^^^^^^^^ AIR303 -12 | backend_kerberos_auth -13 | fab_override +13 | backend_kerberos_auth +14 | fab_override | = help: Install `apache-airflow-provider-fab>=1.0.0` and import from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. -AIR303.py:12:1: AIR303 Import path `airflow.auth_manager.api.auth.backend.kerberos_auth` is moved into `fab` provider in Airflow 3.0; +AIR303.py:13:1: AIR303 Import path `airflow.auth_manager.api.auth.backend.kerberos_auth` is moved into `fab` provider in Airflow 3.0; | -10 | basic_auth, kerberos_auth -11 | auth_current_user -12 | backend_kerberos_auth +11 | basic_auth, kerberos_auth +12 | auth_current_user +13 | backend_kerberos_auth | ^^^^^^^^^^^^^^^^^^^^^ AIR303 -13 | fab_override +14 | fab_override | = help: Install `apache-airflow-provider-fab>=1.0.0` and import from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. -AIR303.py:13:1: AIR303 Import path `airflow.auth.managers.fab.security_manager.override` is moved into `fab` provider in Airflow 3.0; +AIR303.py:14:1: AIR303 Import path `airflow.auth.managers.fab.security_managr.override` is moved into `fab` provider in Airflow 3.0; | -11 | auth_current_user -12 | backend_kerberos_auth -13 | fab_override +12 | auth_current_user +13 | backend_kerberos_auth +14 | fab_override | ^^^^^^^^^^^^ AIR303 -14 | -15 | FabAuthManager +15 | +16 | FabAuthManager | = help: Install `apache-airflow-provider-fab>=1.0.0` and import from `airflow.providers.fab.auth_manager.security_manager.override` instead. -AIR303.py:15:1: AIR303 `airflow.auth.managers.fab.fab_auth_manager.FabAuthManager` is moved into `fab` provider in Airflow 3.0; +AIR303.py:16:1: AIR303 `airflow.auth.managers.fab.fab_auth_manager.FabAuthManager` is moved into `fab` provider in Airflow 3.0; | -13 | fab_override -14 | -15 | FabAuthManager +14 | fab_override +15 | +16 | FabAuthManager | ^^^^^^^^^^^^^^ AIR303 -16 | FabAirflowSecurityManagerOverride +17 | FabAirflowSecurityManagerOverride | = help: Install `apache-airflow-provider-fab>=1.0.0` and use `airflow.providers.fab.auth_manager.security_manager.FabAuthManager` instead. -AIR303.py:16:1: AIR303 `airflow.www.security.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; +AIR303.py:17:1: AIR303 `airflow.www.security.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; | -15 | FabAuthManager -16 | FabAirflowSecurityManagerOverride +16 | FabAuthManager +17 | FabAirflowSecurityManagerOverride | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR303 +18 | +19 | DEFAULT_CELERY_CONFIG | = help: Install `apache-airflow-provider-fab>=1.0.0` and use `airflow.providers.fab.auth_manager.security_manager.override.FabAirflowSecurityManagerOverride` instead. + +AIR303.py:19:1: AIR303 Import path `airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG` is moved into `celery` provider in Airflow 3.0; + | +17 | FabAirflowSecurityManagerOverride +18 | +19 | DEFAULT_CELERY_CONFIG + | ^^^^^^^^^^^^^^^^^^^^^ AIR303 + | + = help: Install `apache-airflow-provider-celery>=3.3.0` and import from `airflow.providers.celery.executors.default_celery.DEFAULT_CELERY_CONFIG` instead.