kaxil commented on code in PR #66102:
URL: https://github.com/apache/airflow/pull/66102#discussion_r3171539178
##########
task-sdk/src/airflow/sdk/definitions/timetables/_cron.py:
##########
@@ -27,13 +27,26 @@
from pendulum.tz.timezone import FixedTimezone, Timezone
+CRON_PRESETS: dict[str, str] = {
+ "@hourly": "0 * * * *",
+ "@daily": "0 0 * * *",
+ "@weekly": "0 0 * * 0",
+ "@monthly": "0 0 1 * *",
+ "@quarterly": "0 0 1 */3 *",
+ "@yearly": "0 0 1 1 *",
+}
+
+
@attrs.define
class CronMixin:
"""Mixin to provide interface to work with croniter."""
expression: str
timezone: str | Timezone | FixedTimezone
+ def __attrs_post_init__(self) -> None:
+ self.expression = CRON_PRESETS.get(self.expression, self.expression)
Review Comment:
nit: Worth a brief comment explaining that self.expression is being
normalised in place. After this runs, the original preset string is lost:
attrs.evolve, equality, and serialisation all see the resolved cron expression.
That matches the legacy core CronMixin (which stored _expression
post-resolution), so it's deliberate, but a one-line comment would save the
next reader a trip through git blame.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]