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 c61c9e4c6c3 Migrate airbyte provider to ``common.compat`` (#56996)
c61c9e4c6c3 is described below
commit c61c9e4c6c382d37d1c54bde70dbacc81c1f2279
Author: Kaxil Naik <[email protected]>
AuthorDate: Wed Oct 22 03:38:44 2025 +0100
Migrate airbyte provider to ``common.compat`` (#56996)
Replace version-specific conditional imports with ``common.compat`` layer.
This standardizes compatibility handling across Airflow 2.x and 3.x.
---
dev/breeze/tests/test_selective_checks.py | 24 +++++++++++++++-------
providers/airbyte/pyproject.toml | 2 ++
.../src/airflow/providers/airbyte/hooks/airbyte.py | 2 +-
.../airflow/providers/airbyte/operators/airbyte.py | 4 ++--
.../airflow/providers/airbyte/sensors/airbyte.py | 4 ++--
.../airflow/providers/airbyte/version_compat.py | 17 ---------------
6 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/dev/breeze/tests/test_selective_checks.py
b/dev/breeze/tests/test_selective_checks.py
index 0e75dca5f1e..9b26f038502 100644
--- a/dev/breeze/tests/test_selective_checks.py
+++ b/dev/breeze/tests/test_selective_checks.py
@@ -731,7 +731,7 @@ def assert_outputs_are_printed(expected_outputs: dict[str,
str], stderr: str):
"providers/airbyte/tests/file.py",
),
{
- "selected-providers-list-as-string": "airbyte",
+ "selected-providers-list-as-string": "airbyte
common.compat",
"all-python-versions":
f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']",
"all-python-versions-list-as-string":
DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
"python-versions":
f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']",
@@ -749,7 +749,12 @@ def assert_outputs_are_printed(expected_outputs: dict[str,
str], stderr: str):
[{"description": "Always", "test_types": "Always"}]
),
"providers-test-types-list-as-strings-in-json": json.dumps(
- [{"description": "airbyte", "test_types":
"Providers[airbyte]"}]
+ [
+ {
+ "description": "airbyte,common.compat",
+ "test_types":
"Providers[airbyte,common.compat]",
+ }
+ ]
),
},
id="Helm tests, airbyte providers, kubernetes tests and "
@@ -857,7 +862,7 @@ def assert_outputs_are_printed(expected_outputs: dict[str,
str], stderr: str):
pytest.param(
("providers/airbyte/tests/airbyte/__init__.py",),
{
- "selected-providers-list-as-string": "airbyte",
+ "selected-providers-list-as-string": "airbyte common.compat",
"all-python-versions":
f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']",
"all-python-versions-list-as-string":
DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
"python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']",
@@ -875,7 +880,12 @@ def assert_outputs_are_printed(expected_outputs: dict[str,
str], stderr: str):
[{"description": "Always", "test_types": "Always"}]
),
"providers-test-types-list-as-strings-in-json": json.dumps(
- [{"description": "airbyte", "test_types":
"Providers[airbyte]"}]
+ [
+ {
+ "description": "airbyte,common.compat",
+ "test_types": "Providers[airbyte,common.compat]",
+ }
+ ]
),
"run-mypy": "true",
"mypy-checks": "['mypy-providers']",
@@ -2125,14 +2135,14 @@ def test_upgrade_to_newer_dependencies(
pytest.param(
("providers/airbyte/docs/some_file.rst",),
{
- "docs-list-as-string": "airbyte",
+ "docs-list-as-string": "airbyte common.compat",
},
id="Airbyte provider docs changed",
),
pytest.param(
("providers/airbyte/docs/some_file.rst",
"airflow-core/docs/docs.rst"),
{
- "docs-list-as-string": "apache-airflow airbyte",
+ "docs-list-as-string": "apache-airflow airbyte common.compat",
},
id="Airbyte provider and airflow core docs changed",
),
@@ -2143,7 +2153,7 @@ def test_upgrade_to_newer_dependencies(
"providers-summary-docs/docs.rst",
),
{
- "docs-list-as-string": "apache-airflow
apache-airflow-providers airbyte",
+ "docs-list-as-string": "apache-airflow
apache-airflow-providers airbyte common.compat",
},
id="Airbyte provider and airflow core and common provider docs
changed",
),
diff --git a/providers/airbyte/pyproject.toml b/providers/airbyte/pyproject.toml
index bf5b725c6ec..9a410d2027e 100644
--- a/providers/airbyte/pyproject.toml
+++ b/providers/airbyte/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
"airbyte-api>=0.52.0",
"requests>=2.32.0",
]
@@ -67,6 +68,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/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py
b/providers/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py
index 7708a43f98b..494ab660b25 100644
--- a/providers/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py
+++ b/providers/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py
@@ -26,7 +26,7 @@ from airbyte_api.models import JobCreateRequest,
JobStatusEnum, JobTypeEnum, Sch
from requests import Session
from airflow.exceptions import AirflowException
-from airflow.providers.airbyte.version_compat import BaseHook
+from airflow.providers.common.compat.sdk import BaseHook
T = TypeVar("T", bound=Any)
diff --git
a/providers/airbyte/src/airflow/providers/airbyte/operators/airbyte.py
b/providers/airbyte/src/airflow/providers/airbyte/operators/airbyte.py
index dc9dd346fdd..aed45ce38a2 100644
--- a/providers/airbyte/src/airflow/providers/airbyte/operators/airbyte.py
+++ b/providers/airbyte/src/airflow/providers/airbyte/operators/airbyte.py
@@ -27,10 +27,10 @@ from airflow.configuration import conf
from airflow.exceptions import AirflowException
from airflow.providers.airbyte.hooks.airbyte import AirbyteHook
from airflow.providers.airbyte.triggers.airbyte import AirbyteSyncTrigger
-from airflow.providers.airbyte.version_compat import BaseOperator
+from airflow.providers.common.compat.sdk import BaseOperator
if TYPE_CHECKING:
- from airflow.providers.airbyte.version_compat import Context
+ from airflow.providers.common.compat.sdk import Context
class AirbyteTriggerSyncOperator(BaseOperator):
diff --git a/providers/airbyte/src/airflow/providers/airbyte/sensors/airbyte.py
b/providers/airbyte/src/airflow/providers/airbyte/sensors/airbyte.py
index 8e802791271..68d2acea220 100644
--- a/providers/airbyte/src/airflow/providers/airbyte/sensors/airbyte.py
+++ b/providers/airbyte/src/airflow/providers/airbyte/sensors/airbyte.py
@@ -29,10 +29,10 @@ from airflow.configuration import conf
from airflow.exceptions import AirflowException
from airflow.providers.airbyte.hooks.airbyte import AirbyteHook
from airflow.providers.airbyte.triggers.airbyte import AirbyteSyncTrigger
-from airflow.providers.airbyte.version_compat import BaseSensorOperator
+from airflow.providers.common.compat.sdk import BaseSensorOperator
if TYPE_CHECKING:
- from airflow.providers.airbyte.version_compat import Context
+ from airflow.providers.common.compat.sdk import Context
class AirbyteJobSensor(BaseSensorOperator):
diff --git a/providers/airbyte/src/airflow/providers/airbyte/version_compat.py
b/providers/airbyte/src/airflow/providers/airbyte/version_compat.py
index da458b9effc..a4fae50317e 100644
--- a/providers/airbyte/src/airflow/providers/airbyte/version_compat.py
+++ b/providers/airbyte/src/airflow/providers/airbyte/version_compat.py
@@ -35,24 +35,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: 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",
]