You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by el...@apache.org on 2025/10/22 05:33:18 UTC

(airflow) branch main updated: Migrate git provider to ``common.compat`` (#57008)

This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new d6628a5c6f5 Migrate git provider to ``common.compat`` (#57008)
d6628a5c6f5 is described below

commit d6628a5c6f5a196eb2d9119e20cb937d91f4359d
Author: Kaxil Naik <ka...@apache.org>
AuthorDate: Wed Oct 22 06:33:12 2025 +0100

    Migrate git provider to ``common.compat`` (#57008)
    
    Replace version-specific conditional imports with ``common.compat`` layer.
    This standardizes compatibility handling across Airflow 2.x and 3.x.
---
 providers/git/pyproject.toml                              | 2 ++
 providers/git/src/airflow/providers/git/hooks/git.py      | 2 +-
 providers/git/src/airflow/providers/git/version_compat.py | 7 +------
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/providers/git/pyproject.toml b/providers/git/pyproject.toml
index dd31093a590..eba23ea917c 100644
--- a/providers/git/pyproject.toml
+++ b/providers/git/pyproject.toml
@@ -58,6 +58,7 @@ requires-python = ">=3.10"
 # After you modify the dependencies, and rebuild your Breeze CI image with ``breeze ci-image build``
 dependencies = [
     "apache-airflow>=3.0.0",
+    "apache-airflow-providers-common-compat>=1.7.4",    # + TODO: bump to next version
     "GitPython>=3.1.44",
 ]
 
@@ -66,6 +67,7 @@ dev = [
     "apache-airflow",
     "apache-airflow-task-sdk",
     "apache-airflow-devel-common",
+    "apache-airflow-providers-common-compat",
     # Additional devel dependencies (do not remove this line and add extra development dependencies)
 ]
 
diff --git a/providers/git/src/airflow/providers/git/hooks/git.py b/providers/git/src/airflow/providers/git/hooks/git.py
index 80b50d526f6..60964fe9f4d 100644
--- a/providers/git/src/airflow/providers/git/hooks/git.py
+++ b/providers/git/src/airflow/providers/git/hooks/git.py
@@ -25,7 +25,7 @@ import tempfile
 from typing import Any
 
 from airflow.exceptions import AirflowException
-from airflow.providers.git.version_compat import BaseHook
+from airflow.providers.common.compat.sdk import BaseHook
 
 log = logging.getLogger(__name__)
 
diff --git a/providers/git/src/airflow/providers/git/version_compat.py b/providers/git/src/airflow/providers/git/version_compat.py
index fbb542e4490..f5bb3ae555c 100644
--- a/providers/git/src/airflow/providers/git/version_compat.py
+++ b/providers/git/src/airflow/providers/git/version_compat.py
@@ -35,9 +35,4 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
 AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
 AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
 
-if AIRFLOW_V_3_1_PLUS:
-    from airflow.sdk import BaseHook
-else:
-    from airflow.hooks.base import BaseHook  # type: ignore[attr-defined,no-redef]
-
-__all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS", "BaseHook"]
+__all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS"]