This is an automated email from the ASF dual-hosted git repository.

husseinawala 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 97091b1784 Improve importing the module in Airflow sensors package 
(#33801)
97091b1784 is described below

commit 97091b178474d6254868f16ac597b00977e92fdf
Author: Hussein Awala <[email protected]>
AuthorDate: Sun Aug 27 21:57:16 2023 +0200

    Improve importing the module in Airflow sensors package (#33801)
---
 airflow/sensors/base.py        | 6 ++++--
 airflow/sensors/bash.py        | 6 ++++--
 airflow/sensors/date_time.py   | 6 ++++--
 airflow/sensors/filesystem.py  | 6 ++++--
 airflow/sensors/python.py      | 7 +++++--
 airflow/sensors/time_delta.py  | 6 +++++-
 airflow/sensors/time_sensor.py | 5 ++++-
 airflow/sensors/weekday.py     | 6 ++++--
 8 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/airflow/sensors/base.py b/airflow/sensors/base.py
index 719bc26a1e..1a505f5de6 100644
--- a/airflow/sensors/base.py
+++ b/airflow/sensors/base.py
@@ -24,7 +24,7 @@ import logging
 import time
 import traceback
 from datetime import timedelta
-from typing import Any, Callable, Iterable
+from typing import TYPE_CHECKING, Any, Callable, Iterable
 
 from airflow import settings
 from airflow.configuration import conf
@@ -43,13 +43,15 @@ from airflow.models.skipmixin import SkipMixin
 from airflow.models.taskreschedule import TaskReschedule
 from airflow.ti_deps.deps.ready_to_reschedule import ReadyToRescheduleDep
 from airflow.utils import timezone
-from airflow.utils.context import Context
 
 # We need to keep the import here because GCSToLocalFilesystemOperator 
released in
 # Google Provider before 3.0.0 imported apply_defaults from here.
 # See  https://github.com/apache/airflow/issues/16035
 from airflow.utils.decorators import apply_defaults  # noqa: F401
 
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
 # As documented in https://dev.mysql.com/doc/refman/5.7/en/datetime.html.
 _MYSQL_TIMESTAMP_MAX = datetime.datetime(2038, 1, 19, 3, 14, 7, 
tzinfo=timezone.utc)
 
diff --git a/airflow/sensors/bash.py b/airflow/sensors/bash.py
index 25c4a547b8..4ec90d672a 100644
--- a/airflow/sensors/bash.py
+++ b/airflow/sensors/bash.py
@@ -20,11 +20,13 @@ from __future__ import annotations
 import os
 from subprocess import PIPE, STDOUT, Popen
 from tempfile import NamedTemporaryFile, TemporaryDirectory, gettempdir
-from typing import Sequence
+from typing import TYPE_CHECKING, Sequence
 
 from airflow.exceptions import AirflowFailException
 from airflow.sensors.base import BaseSensorOperator
-from airflow.utils.context import Context
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
 
 
 class BashSensor(BaseSensorOperator):
diff --git a/airflow/sensors/date_time.py b/airflow/sensors/date_time.py
index 2ac17ca1b6..f1a61540c1 100644
--- a/airflow/sensors/date_time.py
+++ b/airflow/sensors/date_time.py
@@ -18,12 +18,14 @@
 from __future__ import annotations
 
 import datetime
-from typing import Sequence
+from typing import TYPE_CHECKING, Sequence
 
 from airflow.sensors.base import BaseSensorOperator
 from airflow.triggers.temporal import DateTimeTrigger
 from airflow.utils import timezone
-from airflow.utils.context import Context
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
 
 
 class DateTimeSensor(BaseSensorOperator):
diff --git a/airflow/sensors/filesystem.py b/airflow/sensors/filesystem.py
index d2d006818f..65498557bb 100644
--- a/airflow/sensors/filesystem.py
+++ b/airflow/sensors/filesystem.py
@@ -20,11 +20,13 @@ from __future__ import annotations
 import datetime
 import os
 from glob import glob
-from typing import Sequence
+from typing import TYPE_CHECKING, Sequence
 
 from airflow.hooks.filesystem import FSHook
 from airflow.sensors.base import BaseSensorOperator
-from airflow.utils.context import Context
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
 
 
 class FileSensor(BaseSensorOperator):
diff --git a/airflow/sensors/python.py b/airflow/sensors/python.py
index 0a91031fd6..c44708b2f6 100644
--- a/airflow/sensors/python.py
+++ b/airflow/sensors/python.py
@@ -17,12 +17,15 @@
 # under the License.
 from __future__ import annotations
 
-from typing import Any, Callable, Mapping, Sequence
+from typing import TYPE_CHECKING, Any, Callable, Mapping, Sequence
 
 from airflow.sensors.base import BaseSensorOperator, PokeReturnValue
-from airflow.utils.context import Context, context_merge
+from airflow.utils.context import context_merge
 from airflow.utils.operator_helpers import determine_kwargs
 
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
 
 class PythonSensor(BaseSensorOperator):
     """
diff --git a/airflow/sensors/time_delta.py b/airflow/sensors/time_delta.py
index dfedcd706f..3595e551b0 100644
--- a/airflow/sensors/time_delta.py
+++ b/airflow/sensors/time_delta.py
@@ -17,11 +17,15 @@
 # under the License.
 from __future__ import annotations
 
+from typing import TYPE_CHECKING
+
 from airflow.exceptions import AirflowSkipException
 from airflow.sensors.base import BaseSensorOperator
 from airflow.triggers.temporal import DateTimeTrigger
 from airflow.utils import timezone
-from airflow.utils.context import Context
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
 
 
 class TimeDeltaSensor(BaseSensorOperator):
diff --git a/airflow/sensors/time_sensor.py b/airflow/sensors/time_sensor.py
index c459003090..0701a1c244 100644
--- a/airflow/sensors/time_sensor.py
+++ b/airflow/sensors/time_sensor.py
@@ -18,11 +18,14 @@
 from __future__ import annotations
 
 import datetime
+from typing import TYPE_CHECKING
 
 from airflow.sensors.base import BaseSensorOperator
 from airflow.triggers.temporal import DateTimeTrigger
 from airflow.utils import timezone
-from airflow.utils.context import Context
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
 
 
 class TimeSensor(BaseSensorOperator):
diff --git a/airflow/sensors/weekday.py b/airflow/sensors/weekday.py
index 1cc3e36ddf..ba88ee14d6 100644
--- a/airflow/sensors/weekday.py
+++ b/airflow/sensors/weekday.py
@@ -18,14 +18,16 @@
 from __future__ import annotations
 
 import warnings
-from typing import Iterable
+from typing import TYPE_CHECKING, Iterable
 
 from airflow.exceptions import RemovedInAirflow3Warning
 from airflow.sensors.base import BaseSensorOperator
 from airflow.utils import timezone
-from airflow.utils.context import Context
 from airflow.utils.weekday import WeekDay
 
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
 
 class DayOfWeekSensor(BaseSensorOperator):
     """

Reply via email to