This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v2-10-test by this push:
new 0de7eb7d6f3 [v2-10-test] Adding type checking assert to cron.get_next
(#49127) (#49156)
0de7eb7d6f3 is described below
commit 0de7eb7d6f3a4ac6aa3274f176f32f11e9180cdf
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Apr 12 16:17:15 2025 +0200
[v2-10-test] Adding type checking assert to cron.get_next (#49127) (#49156)
(cherry picked from commit 93a56355038a4bc715186ee2732f9ae2337e71ca)
Co-authored-by: Amogh Desai <[email protected]>
---
airflow/timetables/_cron.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/airflow/timetables/_cron.py b/airflow/timetables/_cron.py
index 9b47e9bb3a4..157ee7311af 100644
--- a/airflow/timetables/_cron.py
+++ b/airflow/timetables/_cron.py
@@ -108,6 +108,8 @@ class CronMixin:
naive = make_naive(current, self._timezone)
cron = croniter(self._expression, start_time=naive)
scheduled = cron.get_next(datetime.datetime)
+ if TYPE_CHECKING:
+ assert isinstance(scheduled, datetime.datetime)
if not _covers_every_hour(cron):
return convert_to_utc(make_aware(scheduled, self._timezone))
delta = scheduled - naive
@@ -118,6 +120,8 @@ class CronMixin:
naive = make_naive(current, self._timezone)
cron = croniter(self._expression, start_time=naive)
scheduled = cron.get_prev(datetime.datetime)
+ if TYPE_CHECKING:
+ assert isinstance(scheduled, datetime.datetime)
if not _covers_every_hour(cron):
return convert_to_utc(make_aware(scheduled, self._timezone))
delta = naive - scheduled