Repository navigation
Make cron timetables hashable - #73859
Conversation
Signed-off-by: Adam <111773160+Pebble32@users.noreply.github.com>
Signed-off-by: Adam <111773160+Pebble32@users.noreply.github.com>
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
Signed-off-by: Adam <111773160+Pebble32@users.noreply.github.com>
|
Root cause fix on the pendulum side: python-pendulum/pendulum#1021 |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
|
Hi maintainer, this PR was merged without a milestone set.
|
Backport failed to create: v3-3-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 5eba743 v3-3-testThis should apply the commit to the v3-3-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
namanjain24-sudo
left a comment
There was a problem hiding this comment.
Nice fix — using `str(self._timezone)` is a good general approach: it also fixes `FixedTimezone` instances (e.g. from an integer UTC-offset), which are independently unhashable in pendulum for the same reason (`eq` defined without `hash`), not just named `Timezone`/`ZoneInfo` timezones. Confirmed it also covers `CronDataIntervalTimetable` and `CronPartitionTimetable` since they all share `CronMixin`.
One minor edge case worth being aware of (not blocking, and not reachable through Airflow's own `parse_timezone`): `FixedTimezone.eq` only compares `_offset`, but `str()`/`repr()` also encodes `name`, so two `FixedTimezone` instances with the same offset but different explicit names would be `==` but hash differently. Only matters if something constructs a `FixedTimezone` directly with a custom name rather than going through `parse_timezone`, which only ever produces the offset-derived default name.
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
|
(Formatting fix — the backticks in my review above got double-escaped and render literally. Reposting cleanly:) Nice fix — using One minor edge case worth being aware of (not blocking, and not reachable through Airflow's own Drafted-by: Claude Code (Sonnet 5) (no human review before posting) |
hash()on any cron-based timetable raises, becauseCronMixin.__hash__puts the pendulumTimezoneobject, which is unhashable, into the hashed tuple:Hash the timezone name instead, which is what
__eq__effectively compares, so equal timetables still hash equal.Found while working on #72475, where the fix rode along; split out here as suggested in review since it is an independent bugfix that can land and be backported on its own.
Tests
test_cron_timetables_are_hashableintest_trigger_timetable.py:hash()no longer raises, and two equal timetables hash equal.Was generative AI tooling used to co-author this PR?
Generated-by: Claude (Claude Code), following the guidelines
related: #72475