You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Hypothesis test strategy for timezones (pyarrow.tests.strategies.timezones) only generates named IANA timezones (via pytz and zoneinfo). It does not generate fixed-offset timezones like +05:30 or -03:00. As noted in #31318, this is not supported out of the box by Hypothesis, so a custom strategy is needed. Fixed-offset timezones are already used in manual tests and handled correctly by Arrow, but are never exercised via property-based testing.
What changes are included in this PR?
Adds a fixed_offset_timezones strategy to python/pyarrow/tests/strategies.py that generates datetime.timezone objects with offsets ranging from UTC-12:00 to UTC+14:00, with minute components of 0, 30, or 45 (covering all real-world UTC offsets). This strategy is included in the existing timezones strategy across all dependency configurations.
Are these changes tested?
This change improves test infrastructure itself -- it extends the timezones strategy used by existing Hypothesis-based tests. The generated fixed-offset timezones were verified to work correctly with pa.timestamp().
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
The only comment I have for now is that the current strategy can produce UTC out of the valid UTC range which is UTC-12 and UTC+14, for example UTC-12:45. Datetime will accept it but as this is invalid IANA timezone it should be improved, it also might produce errors in other parts.
@AlenkaF thanks for the review!
You're right. I've pushed a follow-up that enforces both bounds, making sure that no offset fails outside the valid UTC-12 to UTC+14 range. Can you please re-check?
edit: on hindsight, a lower bound filter is unnecessary since the lower bound can never be violated -- harmless, clear and defensive, but dead code.
Thanks for the update! There is a PR up to fix the hypothesis build: #49847. After that is merged you can rebase and we can run the build here, to double check the logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The Hypothesis test strategy for timezones (
pyarrow.tests.strategies.timezones) only generates named IANA timezones (via pytz and zoneinfo). It does not generate fixed-offset timezones like+05:30or-03:00. As noted in #31318, this is not supported out of the box by Hypothesis, so a custom strategy is needed. Fixed-offset timezones are already used in manual tests and handled correctly by Arrow, but are never exercised via property-based testing.What changes are included in this PR?
Adds a
fixed_offset_timezonesstrategy topython/pyarrow/tests/strategies.pythat generatesdatetime.timezoneobjects with offsets ranging from UTC-12:00 to UTC+14:00, with minute components of 0, 30, or 45 (covering all real-world UTC offsets). This strategy is included in the existingtimezonesstrategy across all dependency configurations.Are these changes tested?
This change improves test infrastructure itself -- it extends the
timezonesstrategy used by existing Hypothesis-based tests. The generated fixed-offset timezones were verified to work correctly withpa.timestamp().The test command used was:
Are there any user-facing changes?
No. This only affects the internal test suite.
AI-generated code disclosure
This PR was developed with assistance from an AI coding tool (Claude, Anthropic). All changes have been reviewed, understood, and verified.
Closes [Python] Update timezones strategy to include fixed offsets #31318