Repository navigation
Skip out-of-range month spans during date searches - #1568
Closed
Yongthyuan wants to merge 1 commit into
Closed
Yongthyuan wants to merge 1 commit into
Yongthyuan wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
With
RETURN_TIME_SPAN=True, an out-of-range month span raisesValueErrorand preventssearch_dates()from returning other valid dates in the text:The existing guard handles
OverflowErrorfromtimedeltaarithmetic, but month spans userelativedelta, which raisesValueErrorwhen the resulting year is outside the supported range. Catch both exceptions around span generation so an unrepresentable span is omitted while previously parsed dates are retained.Six regression cases cover past and future month spans, including preservation of another date with both the
splitandngramsearch strategies. All six fail on the unmodified base and pass with the fix.Validation on macOS arm64, Python 3.12.13, with
TZ=UTC:pytest tests/test_long_digit_runs.py tests/test_search.py -q: 462 passed, 31 subtests passed.pytest -q: 25,313 passed, 9 skipped, 4 xfailed, 508 subtests passed.tox -e pre-commit: passed (Ruff lint/format and zizmor).Other supported Python versions and optional calendar/language-detection dependencies were not tested locally.
Assisted by Codex.