Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
import segment.analytics as analytics

from airflow.exceptions import AirflowException

try:
from airflow.sdk import BaseHook
except ImportError:
from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]
from airflow.providers.segment.version_compat import BaseHook


class SegmentHook(BaseHook):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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_0_PLUS:
from airflow.sdk import BaseOperator
Expand All @@ -42,9 +42,15 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
from airflow.models import BaseOperator # type: ignore[no-redef]
from airflow.utils.context import Context # type: ignore[no-redef]

if AIRFLOW_V_3_1_PLUS:
from airflow.sdk import BaseHook
else:
from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]

# Explicitly export these imports to protect them from being removed by linters
__all__ = [
"AIRFLOW_V_3_0_PLUS",
"BaseHook",
"BaseOperator",
"Context",
]