From 40431e574fb30c7979411b7f5ad2137c8a6528ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sun, 24 Nov 2024 12:08:46 +0200 Subject: [PATCH] Removed the obsolete `timedelta_seconds` function --- src/apscheduler/schedulers/base.py | 3 +-- src/apscheduler/triggers/interval.py | 5 ++--- src/apscheduler/util.py | 1 - tests/test_util.py | 7 ------- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/apscheduler/schedulers/base.py b/src/apscheduler/schedulers/base.py index 4d641d15..6f416902 100644 --- a/src/apscheduler/schedulers/base.py +++ b/src/apscheduler/schedulers/base.py @@ -44,7 +44,6 @@ asint, astimezone, maybe_ref, - timedelta_seconds, undefined, ) @@ -1151,7 +1150,7 @@ def _process_jobs(self): else: now = datetime.now(self.timezone) wait_seconds = min( - max(timedelta_seconds(next_wakeup_time - now), 0), TIMEOUT_MAX + max((next_wakeup_time - now).total_seconds(), 0), TIMEOUT_MAX ) self._logger.debug( "Next wakeup is due at %s (in %f seconds)", diff --git a/src/apscheduler/triggers/interval.py b/src/apscheduler/triggers/interval.py index b1b63797..9264c4ac 100644 --- a/src/apscheduler/triggers/interval.py +++ b/src/apscheduler/triggers/interval.py @@ -9,7 +9,6 @@ astimezone, convert_to_datetime, datetime_repr, - timedelta_seconds, ) @@ -53,7 +52,7 @@ def __init__( self.interval = timedelta( weeks=weeks, days=days, hours=hours, minutes=minutes, seconds=seconds ) - self.interval_length = timedelta_seconds(self.interval) + self.interval_length = self.interval.total_seconds() if self.interval_length == 0: self.interval = timedelta(seconds=1) self.interval_length = 1 @@ -116,7 +115,7 @@ def __setstate__(self, state): self.start_date = state["start_date"] self.end_date = state["end_date"] self.interval = state["interval"] - self.interval_length = timedelta_seconds(self.interval) + self.interval_length = self.interval.total_seconds() self.jitter = state.get("jitter") def __str__(self): diff --git a/src/apscheduler/util.py b/src/apscheduler/util.py index 8cbbb957..82eb8c07 100644 --- a/src/apscheduler/util.py +++ b/src/apscheduler/util.py @@ -7,7 +7,6 @@ "convert_to_datetime", "datetime_to_utc_timestamp", "utc_timestamp_to_datetime", - "timedelta_seconds", "datetime_ceil", "get_callable_name", "obj_to_ref", diff --git a/tests/test_util.py b/tests/test_util.py index d0dc4d94..bfc634d2 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -24,7 +24,6 @@ maybe_ref, obj_to_ref, ref_to_obj, - timedelta_seconds, utc_timestamp_to_datetime, ) @@ -207,12 +206,6 @@ def test_datetime_to_utc_timestamp(timezone): assert dt2 == dt -def test_timedelta_seconds(): - delta = timedelta(minutes=2, seconds=30) - seconds = timedelta_seconds(delta) - assert seconds == 150 - - @pytest.mark.parametrize( "input,expected", [