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

kaxilnaik 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 560a5fe270e Migrate `http` provider to `common.compat` (#57089)
560a5fe270e is described below

commit 560a5fe270ea42b57994b4fdfe551f60fc2848e0
Author: ChenChen Lai <[email protected]>
AuthorDate: Thu Oct 23 23:42:38 2025 +0800

    Migrate `http` provider to `common.compat` (#57089)
    
    * Migrate remaining providers to common.compat compatibility layer in http
    
    * fix falling test
    
    * Apply suggestion from @kaxil
    
    ---------
    
    Co-authored-by: Kaxil Naik <[email protected]>
---
 providers/http/pyproject.toml                           |  1 +
 providers/http/src/airflow/providers/http/hooks/http.py |  2 +-
 .../http/src/airflow/providers/http/operators/http.py   |  2 +-
 .../http/src/airflow/providers/http/sensors/http.py     |  4 +++-
 .../http/src/airflow/providers/http/triggers/http.py    |  2 +-
 .../http/src/airflow/providers/http/version_compat.py   | 17 ++++-------------
 6 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/providers/http/pyproject.toml b/providers/http/pyproject.toml
index b70fc9f6005..5c182328f45 100644
--- a/providers/http/pyproject.toml
+++ b/providers/http/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.8.0",
     # The 2.26.0 release of requests got rid of the chardet LGPL mandatory 
dependency, allowing us to
     # release it as a requirement for airflow
     "requests>=2.32.0,<3",
diff --git a/providers/http/src/airflow/providers/http/hooks/http.py 
b/providers/http/src/airflow/providers/http/hooks/http.py
index b8baa580c41..0c8dd7d0bc2 100644
--- a/providers/http/src/airflow/providers/http/hooks/http.py
+++ b/providers/http/src/airflow/providers/http/hooks/http.py
@@ -33,8 +33,8 @@ from requests.models import DEFAULT_REDIRECT_LIMIT
 from requests_toolbelt.adapters.socket_options import TCPKeepAliveAdapter
 
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.sdk import BaseHook
 from airflow.providers.http.exceptions import HttpErrorException, 
HttpMethodException
-from airflow.providers.http.version_compat import BaseHook
 
 if TYPE_CHECKING:
     from aiohttp.client_reqrep import ClientResponse
diff --git a/providers/http/src/airflow/providers/http/operators/http.py 
b/providers/http/src/airflow/providers/http/operators/http.py
index 4915339e49f..52938e73377 100644
--- a/providers/http/src/airflow/providers/http/operators/http.py
+++ b/providers/http/src/airflow/providers/http/operators/http.py
@@ -27,8 +27,8 @@ from requests import Response
 
 from airflow.configuration import conf
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.sdk import BaseHook, BaseOperator
 from airflow.providers.http.triggers.http import HttpTrigger, 
serialize_auth_type
-from airflow.providers.http.version_compat import BaseHook, BaseOperator
 from airflow.utils.helpers import merge_dicts
 
 if TYPE_CHECKING:
diff --git a/providers/http/src/airflow/providers/http/sensors/http.py 
b/providers/http/src/airflow/providers/http/sensors/http.py
index f395ab2bb8c..5ad277067d9 100644
--- a/providers/http/src/airflow/providers/http/sensors/http.py
+++ b/providers/http/src/airflow/providers/http/sensors/http.py
@@ -23,11 +23,13 @@ from typing import TYPE_CHECKING, Any
 
 from airflow.configuration import conf
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.sdk import BaseSensorOperator
 from airflow.providers.http.hooks.http import HttpHook
 from airflow.providers.http.triggers.http import HttpSensorTrigger
-from airflow.providers.http.version_compat import AIRFLOW_V_3_0_PLUS, 
BaseSensorOperator
 
 if TYPE_CHECKING:
+    from airflow.providers.common.compat.version_compat import 
AIRFLOW_V_3_0_PLUS
+
     try:
         from airflow.sdk.definitions.context import Context
 
diff --git a/providers/http/src/airflow/providers/http/triggers/http.py 
b/providers/http/src/airflow/providers/http/triggers/http.py
index bd29ac71f59..6cddca683d2 100644
--- a/providers/http/src/airflow/providers/http/triggers/http.py
+++ b/providers/http/src/airflow/providers/http/triggers/http.py
@@ -33,8 +33,8 @@ from requests.cookies import RequestsCookieJar
 from requests.structures import CaseInsensitiveDict
 
 from airflow.exceptions import AirflowException
+from airflow.providers.common.compat.version_compat import AIRFLOW_V_3_0_PLUS
 from airflow.providers.http.hooks.http import HttpAsyncHook
-from airflow.providers.http.version_compat import AIRFLOW_V_3_0_PLUS
 from airflow.triggers.base import BaseTrigger, TriggerEvent
 
 if AIRFLOW_V_3_0_PLUS:
diff --git a/providers/http/src/airflow/providers/http/version_compat.py 
b/providers/http/src/airflow/providers/http/version_compat.py
index ef9f9d6c244..a4fae50317e 100644
--- a/providers/http/src/airflow/providers/http/version_compat.py
+++ b/providers/http/src/airflow/providers/http/version_compat.py
@@ -33,18 +33,9 @@ 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
-else:
-    from airflow.models import BaseOperator
-    from airflow.sensors.base import BaseSensorOperator  # type: 
ignore[no-redef]
-
-__all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS", "BaseHook", 
"BaseOperator", "BaseSensorOperator"]
+__all__ = [
+    "AIRFLOW_V_3_0_PLUS",
+    "AIRFLOW_V_3_1_PLUS",
+]

Reply via email to