Repository navigation
Conversation
Arrow.range() accepts "months", "quarters" and "years" through _get_frames(), but the end-of-month day-restore check compared the raw frame argument against the singular names only. After a shorter month the day therefore stayed clipped for the rest of the range, and span_range() inherited the same behaviour. Use the normalized frame name returned by _get_frames() for the check, and add a parametrized regression test for the plural spellings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1354 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Harness. |
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.
Pull Request Checklist
Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
toxormake testto find out!).tox -e lintormake lintto find out!).masterbranch.Description of Changes
Arrow.range()accepts plural frame names ("months","quarters","years") through_get_frames(), and they iterate over the same steps as the singular names. But the end-of-month "restore the clipped day" logic compares the rawframeargument against["month", "quarter", "year"], so it never fires for the plural spellings. After passing through a shorter month, the day stays clipped for the rest of the range:span_range()forwardsframetorange()unchanged, so it was affected in the same way.The fix keeps the normalized frame name that
_get_frames()already returns and uses it for the comparison, so"month"/"months","quarter"/"quarters"and"year"/"years"behave identically. The existing singular-name regression tests (e.g. #842) are unchanged.Tests
Added
TestArrowRange.test_range_plural_frames_restore_clipped_day, parametrized over"months","quarters"and"years"using the same dates as the existing singular-name tests. All three cases fail onmasterand pass with this change.Locally on CPython 3.12:
pytest tests→ 1903 passed, 2 skipped.black --check,flake8andisort --check-onlyare clean on the changed files.mypy arrow/arrow.pyreports 3 errors inhumanize()(lines ~1268–1296) that are identical with and without this change, so they come from my newer mypy version rather than from this PR. I did not run the fulltoxmatrix, only the pytest suite on 3.12 and the linters above.No documentation change: the docstring already lists these frames as supported, and this makes the plural forms behave as documented.
This change was prepared with AI assistance (Claude Code). I reproduced the bug on
master, reviewed the diff and ran the tests and linters described above.🤖 Generated with Claude Code