Skip to content

Commit cfa11c9

Browse files
authored
Migrate remaining providers to common.compat compatibility layer (apache#57073)
1 parent 3e1b02a commit cfa11c9

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

providers/cohere/pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ dependencies = [
6161
"cohere>=5.13.4",
6262
]
6363

64+
# The optional dependencies should be modified in place in the generated file
65+
# Any change in the dependencies is preserved when the file is regenerated
66+
[project.optional-dependencies]
67+
"common.compat" = [
68+
"apache-airflow-providers-common-compat>=1.7.4", # + TODO: bump to next version
69+
]
70+
6471
[dependency-groups]
6572
dev = [
6673
"apache-airflow",
6774
"apache-airflow-task-sdk",
6875
"apache-airflow-devel-common",
76+
"apache-airflow-providers-common-compat",
6977
# Additional devel dependencies (do not remove this line and add extra development dependencies)
7078
]
7179

providers/cohere/src/airflow/providers/cohere/hooks/cohere.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from cohere.types import UserChatMessageV2
2626

2727
from airflow.exceptions import AirflowProviderDeprecationWarning
28-
from airflow.providers.cohere.version_compat import BaseHook
28+
from airflow.providers.common.compat.sdk import BaseHook
2929

3030
if TYPE_CHECKING:
3131
from cohere.core.request_options import RequestOptions

providers/cohere/src/airflow/providers/cohere/operators/embedding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
from typing import TYPE_CHECKING, Any
2323

2424
from airflow.providers.cohere.hooks.cohere import CohereHook
25-
from airflow.providers.cohere.version_compat import BaseOperator
25+
from airflow.providers.common.compat.sdk import BaseOperator
2626

2727
if TYPE_CHECKING:
2828
from cohere.core.request_options import RequestOptions
2929

30-
from airflow.providers.cohere.version_compat import Context
30+
from airflow.providers.common.compat.sdk import Context
3131

3232

3333
class CohereEmbeddingOperator(BaseOperator):

providers/cohere/src/airflow/providers/cohere/version_compat.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,7 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
3030
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
3131
AIRFLOW_V_3_1_PLUS = get_base_airflow_version_tuple() >= (3, 1, 0)
3232

33-
if AIRFLOW_V_3_0_PLUS:
34-
from airflow.sdk import BaseOperator
35-
else:
36-
from airflow.models import BaseOperator
37-
38-
if AIRFLOW_V_3_1_PLUS:
39-
from airflow.sdk import BaseHook
40-
from airflow.sdk.definitions.context import Context
41-
else:
42-
from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]
43-
from airflow.utils.context import Context
44-
4533
__all__ = [
4634
"AIRFLOW_V_3_0_PLUS",
4735
"AIRFLOW_V_3_1_PLUS",
48-
"BaseHook",
49-
"BaseOperator",
50-
"Context",
5136
]

0 commit comments

Comments
 (0)