Skip to content

Reject bool in Arrow.replace/shift integer fields - #1357

Open
Pitchfork-and-Torch wants to merge 1 commit into
arrow-py:masterfrom
Pitchfork-and-Torch:cook/reject-bool-replace-shift
Open

Pitchfork-and-Torch wants to merge 1 commit into
arrow-py:masterfrom
Pitchfork-and-Torch:cook/reject-bool-replace-shift

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

bool is a subclass of int, so calls like arrow.utcnow().replace(year=True) silently set the year to 1, and shift(days=True) shifts by one day. This rejects bool values for calendar/time unit kwargs on replace / shift with TypeError.

fold / tzinfo are unchanged.

Test plan

  • Added test_replace_rejects_bool / test_shift_rejects_bool
  • Existing test_replace / test_shift still pass

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).
Copilot AI lite review requested due to automatic review settings September 18, 2026 03:54
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2224255) to head (c4ae40c).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.replace and Arrow.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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants