Repository navigation
Reject bool in Arrow.replace/shift integer fields - #1357
Open
Pitchfork-and-Torch wants to merge 1 commit into
Open
Pitchfork-and-Torch wants to merge 1 commit into
Pitchfork-and-Torch wants to merge 1 commit into
Conversation
bool is a subclass of int, so replace(year=True) silently became year 1 and shift(days=True) shifted by one day. Raise TypeError for bool values on calendar/time unit kwargs (fold/tzinfo unchanged).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1357 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2319 +4
Branches 358 360 +2
=========================================
+ Hits 2315 2319 +4 ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments remain, and the requested tests are included.
Pull request overview
This pull request rejects boolean values for integer-based replace and shift arguments to prevent unintended date changes.
Changes:
- Added boolean validation in
Arrow.replaceandArrow.shift. - Added regression tests for affected fields.
File summaries
| File | Description |
|---|---|
tests/test_arrow.py |
Tests boolean rejection for replace and shift. |
arrow/arrow.py |
Rejects boolean calendar and shift values. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
boolis a subclass ofint, so calls likearrow.utcnow().replace(year=True)silently set the year to 1, andshift(days=True)shifts by one day. This rejectsboolvalues for calendar/time unit kwargs onreplace/shiftwithTypeError.fold/tzinfoare unchanged.Test plan
test_replace_rejects_bool/test_shift_rejects_booltest_replace/test_shiftstill pass