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 62b441164dd Migrate github provider to ``common.compat`` (#57009)
62b441164dd is described below

commit 62b441164ddb54fbf4dbbe218cf310c87f863fb8
Author: Kaxil Naik <[email protected]>
AuthorDate: Wed Oct 22 06:32:46 2025 +0100

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

diff --git a/providers/github/pyproject.toml b/providers/github/pyproject.toml
index 6552de60969..ed8c3ab98a9 100644
--- a/providers/github/pyproject.toml
+++ b/providers/github/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>=2.10.0",
+    "apache-airflow-providers-common-compat>=1.7.4",    # + TODO: bump to next 
version
     "PyGithub>=2.1.1",
 ]
 
@@ -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/github/src/airflow/providers/github/hooks/github.py 
b/providers/github/src/airflow/providers/github/hooks/github.py
index b964f597140..d0b60d3908c 100644
--- a/providers/github/src/airflow/providers/github/hooks/github.py
+++ b/providers/github/src/airflow/providers/github/hooks/github.py
@@ -24,7 +24,7 @@ from typing import TYPE_CHECKING
 from github import Github as GithubClient
 
 from airflow.exceptions import AirflowException
-from airflow.providers.github.version_compat import BaseHook
+from airflow.providers.common.compat.sdk import BaseHook
 
 
 class GithubHook(BaseHook):
diff --git a/providers/github/src/airflow/providers/github/operators/github.py 
b/providers/github/src/airflow/providers/github/operators/github.py
index c7420e06808..47689d0c14b 100644
--- a/providers/github/src/airflow/providers/github/operators/github.py
+++ b/providers/github/src/airflow/providers/github/operators/github.py
@@ -23,11 +23,11 @@ from typing import TYPE_CHECKING, Any
 from github import GithubException
 
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.sdk import BaseOperator
 from airflow.providers.github.hooks.github import GithubHook
-from airflow.providers.github.version_compat import BaseOperator
 
 if TYPE_CHECKING:
-    from airflow.providers.github.version_compat import Context
+    from airflow.providers.common.compat.sdk import Context
 
 
 class GithubOperator(BaseOperator):
diff --git a/providers/github/src/airflow/providers/github/sensors/github.py 
b/providers/github/src/airflow/providers/github/sensors/github.py
index 0bd61342917..d9dcc8d93af 100644
--- a/providers/github/src/airflow/providers/github/sensors/github.py
+++ b/providers/github/src/airflow/providers/github/sensors/github.py
@@ -23,11 +23,11 @@ from typing import TYPE_CHECKING, Any
 from github import GithubException
 
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.sdk import BaseSensorOperator
 from airflow.providers.github.hooks.github import GithubHook
-from airflow.providers.github.version_compat import BaseSensorOperator
 
 if TYPE_CHECKING:
-    from airflow.providers.github.version_compat import Context
+    from airflow.providers.common.compat.sdk import Context
 
 
 class GithubSensor(BaseSensorOperator):
diff --git a/providers/github/src/airflow/providers/github/version_compat.py 
b/providers/github/src/airflow/providers/github/version_compat.py
index 7a03eaab7d1..f5bb3ae555c 100644
--- a/providers/github/src/airflow/providers/github/version_compat.py
+++ b/providers/github/src/airflow/providers/github/version_compat.py
@@ -35,25 +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]
-
-if AIRFLOW_V_3_0_PLUS:
-    from airflow.sdk import BaseOperator, BaseSensorOperator
-    from airflow.sdk.definitions.context import Context
-else:
-    from airflow.models import BaseOperator
-    from airflow.sensors.base import BaseSensorOperator  # type: 
ignore[no-redef]
-    from airflow.utils.context import Context
-
-
-__all__ = [
-    "AIRFLOW_V_3_0_PLUS",
-    "AIRFLOW_V_3_1_PLUS",
-    "BaseHook",
-    "BaseOperator",
-    "BaseSensorOperator",
-    "Context",
-]
+__all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS"]

Reply via email to