Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelauv committed Dec 9, 2024
1 parent baf9e1c commit 25076d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
14 changes: 4 additions & 10 deletions providers/src/airflow/providers/standard/sensors/time_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from packaging.version import Version

from airflow.configuration import conf
from airflow.exceptions import AirflowSkipException
from airflow.providers.standard.triggers.temporal import DateTimeTrigger, TimeDeltaTrigger
from airflow.providers.standard.utils.version_references import AIRFLOW_V_3_0_PLUS
from airflow.sensors.base import BaseSensorOperator
Expand Down Expand Up @@ -89,15 +88,10 @@ def execute(self, context: Context) -> bool | NoReturn:
if timezone.utcnow() > target_dttm:
# If the target datetime is in the past, return immediately
return True
try:
if AIRFLOW_V_3_0_PLUS:
trigger = DateTimeTrigger(moment=target_dttm, end_from_trigger=self.end_from_trigger)
else:
trigger = DateTimeTrigger(moment=target_dttm)
except (TypeError, ValueError) as e:
if self.soft_fail:
raise AirflowSkipException("Skipping due to soft_fail is set to True.") from e
raise
if AIRFLOW_V_3_0_PLUS:
trigger = DateTimeTrigger(moment=target_dttm, end_from_trigger=self.end_from_trigger)
else:
trigger = DateTimeTrigger(moment=target_dttm)

# todo: remove backcompat when min airflow version greater than 2.11
timeout: int | float | timedelta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
from asgiref.sync import sync_to_async
from sqlalchemy import func

from airflow.sensors.base import FailPolicy
from airflow.models import DagRun
from airflow.providers.standard.utils.sensor_helper import _get_count
from airflow.providers.standard.utils.version_references import AIRFLOW_V_3_0_PLUS
from airflow.sensors.base import FailPolicy
from airflow.triggers.base import BaseTrigger, TriggerEvent
from airflow.utils.session import NEW_SESSION, provide_session

Expand Down
1 change: 0 additions & 1 deletion tests/sensors/test_external_task_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
from tests.models import TEST_DAGS_FOLDER
from tests_common.test_utils.compat import (
AIRFLOW_V_2_10_PLUS,
AIRFLOW_V_3_0_PLUS,
ignore_provider_compatibility_error,
)
from tests_common.test_utils.db import clear_db_runs
Expand Down

0 comments on commit 25076d4

Please sign in to comment.