This is an automated email from the ASF dual-hosted git repository.
potiuk 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 cfa11c92ed3 Migrate remaining providers to common.compat compatibility
layer (#57073)
cfa11c92ed3 is described below
commit cfa11c92ed3f915d49b3e5e926a523a8b501995f
Author: rich7420 <[email protected]>
AuthorDate: Thu Oct 23 04:06:47 2025 +0800
Migrate remaining providers to common.compat compatibility layer (#57073)
---
providers/cohere/pyproject.toml | 8 ++++++++
.../cohere/src/airflow/providers/cohere/hooks/cohere.py | 2 +-
.../src/airflow/providers/cohere/operators/embedding.py | 4 ++--
.../cohere/src/airflow/providers/cohere/version_compat.py | 15 ---------------
4 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/providers/cohere/pyproject.toml b/providers/cohere/pyproject.toml
index d4d05400418..88bcad86503 100644
--- a/providers/cohere/pyproject.toml
+++ b/providers/cohere/pyproject.toml
@@ -61,11 +61,19 @@ dependencies = [
"cohere>=5.13.4",
]
+# The optional dependencies should be modified in place in the generated file
+# Any change in the dependencies is preserved when the file is regenerated
+[project.optional-dependencies]
+"common.compat" = [
+ "apache-airflow-providers-common-compat>=1.7.4", # + TODO: bump to next
version
+]
+
[dependency-groups]
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/cohere/src/airflow/providers/cohere/hooks/cohere.py
b/providers/cohere/src/airflow/providers/cohere/hooks/cohere.py
index 9eb624465bf..848a70edd74 100644
--- a/providers/cohere/src/airflow/providers/cohere/hooks/cohere.py
+++ b/providers/cohere/src/airflow/providers/cohere/hooks/cohere.py
@@ -25,7 +25,7 @@ import cohere
from cohere.types import UserChatMessageV2
from airflow.exceptions import AirflowProviderDeprecationWarning
-from airflow.providers.cohere.version_compat import BaseHook
+from airflow.providers.common.compat.sdk import BaseHook
if TYPE_CHECKING:
from cohere.core.request_options import RequestOptions
diff --git
a/providers/cohere/src/airflow/providers/cohere/operators/embedding.py
b/providers/cohere/src/airflow/providers/cohere/operators/embedding.py
index 40895b48cbd..62270e75708 100644
--- a/providers/cohere/src/airflow/providers/cohere/operators/embedding.py
+++ b/providers/cohere/src/airflow/providers/cohere/operators/embedding.py
@@ -22,12 +22,12 @@ from functools import cached_property
from typing import TYPE_CHECKING, Any
from airflow.providers.cohere.hooks.cohere import CohereHook
-from airflow.providers.cohere.version_compat import BaseOperator
+from airflow.providers.common.compat.sdk import BaseOperator
if TYPE_CHECKING:
from cohere.core.request_options import RequestOptions
- from airflow.providers.cohere.version_compat import Context
+ from airflow.providers.common.compat.sdk import Context
class CohereEmbeddingOperator(BaseOperator):
diff --git a/providers/cohere/src/airflow/providers/cohere/version_compat.py
b/providers/cohere/src/airflow/providers/cohere/version_compat.py
index 95a51051336..03797bc9d4d 100644
--- a/providers/cohere/src/airflow/providers/cohere/version_compat.py
+++ b/providers/cohere/src/airflow/providers/cohere/version_compat.py
@@ -30,22 +30,7 @@ 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 = get_base_airflow_version_tuple() >= (3, 1, 0)
-if AIRFLOW_V_3_0_PLUS:
- from airflow.sdk import BaseOperator
-else:
- from airflow.models import BaseOperator
-
-if AIRFLOW_V_3_1_PLUS:
- from airflow.sdk import BaseHook
- from airflow.sdk.definitions.context import Context
-else:
- from airflow.hooks.base import BaseHook # type:
ignore[attr-defined,no-redef]
- from airflow.utils.context import Context
-
__all__ = [
"AIRFLOW_V_3_0_PLUS",
"AIRFLOW_V_3_1_PLUS",
- "BaseHook",
- "BaseOperator",
- "Context",
]