Skip to content

Commit 1d96f67

Browse files
0lai0kaxil
andauthored
Migrate grpc provider to common.compat (apache#57087)
* Migrate remaining providers to common.compat compatibility layer in grpc * fix grpc static check * Apply suggestion from @kaxil --------- Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
1 parent eb6f2c3 commit 1d96f67

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

providers/grpc/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ requires-python = ">=3.10"
5858
# After you modify the dependencies, and rebuild your Breeze CI image with ``breeze ci-image build``
5959
dependencies = [
6060
"apache-airflow>=2.10.0",
61+
"apache-airflow-providers-common-compat>=1.8.0",
6162
# Google has very clear rules on what dependencies should be used. All the limits below
6263
# follow strict guidelines of Google Libraries as quoted here:
6364
# While this issue is open, dependents of google-api-core, google-cloud-core. and google-auth
@@ -73,6 +74,7 @@ dev = [
7374
"apache-airflow",
7475
"apache-airflow-task-sdk",
7576
"apache-airflow-devel-common",
77+
"apache-airflow-providers-common-compat",
7678
# Additional devel dependencies (do not remove this line and add extra development dependencies)
7779
]
7880

providers/grpc/src/airflow/providers/grpc/hooks/grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131

3232
from airflow.exceptions import AirflowConfigException
33-
from airflow.providers.grpc.version_compat import BaseHook
33+
from airflow.providers.common.compat.sdk import BaseHook
3434

3535

3636
class GrpcHook(BaseHook):

providers/grpc/src/airflow/providers/grpc/operators/grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
from collections.abc import Callable, Sequence
2121
from typing import TYPE_CHECKING, Any
2222

23+
from airflow.providers.common.compat.sdk import BaseOperator
2324
from airflow.providers.grpc.hooks.grpc import GrpcHook
24-
from airflow.providers.grpc.version_compat import BaseOperator
2525

2626
if TYPE_CHECKING:
2727
try:

providers/grpc/src/airflow/providers/grpc/version_compat.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +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: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
3232

33-
if AIRFLOW_V_3_1_PLUS:
34-
from airflow.sdk import BaseHook
35-
else:
36-
from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]
37-
38-
if AIRFLOW_V_3_0_PLUS:
39-
from airflow.sdk import BaseOperator
40-
else:
41-
from airflow.models import BaseOperator
42-
43-
__all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS", "BaseHook", "BaseOperator"]
33+
__all__ = [
34+
"AIRFLOW_V_3_0_PLUS",
35+
"AIRFLOW_V_3_1_PLUS",
36+
]

0 commit comments

Comments
 (0)