Parse month- and day-level consecutives in sets - #94
Merged
cameron-simpson merged 1 commit intoSep 16, 2026
Merged
Conversation
[1774-11..1774-12] and [1785-07-30..1785-08-06] raised TypeError: the results names inside a month or day bound (year, month, day) reached Consecutives.__init__ as keyword arguments, and each bound arrived as a list of its parts. The bounds are now combined into one string, and Consecutives builds itself from the two bounds only.
Member
|
@cameron-simpson please can you look at this one? |
Collaborator
|
This seems correct to me. Thank you @lisboarocha |
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.
Fixes #79.
Sets with a range of months or days did not parse:
Two things went wrong in
consecutives. The results names inside a month or day bound (year,month,day) reached the token dict, soConsecutives(**kwargs)received them as keyword arguments; and each bound arrived as the list of its parts (['1774', '-', '11']) rather than as a string, which is whatyear_basicworks around for years.The fix:
grammar.py: the month and day bounds are wrapped inCombine, so each is one string ("1774-11").parser_classes.py:Consecutives.parse_actionbuilds the object fromlowerandupperonly, taking the combined string out of theParseResultsthatCombinereturns when the bound keeps inner results names.Tests: four examples added to
EXAMPLESintests/test_parser.py, from the issue and the specification's set forms:[1774-11..1774-12]→ 1774-11-01 .. 1774-12-31[1785-07-30..1785-08-06]→ 1785-07-30 .. 1785-08-06[1667, 1912-03..1912-05]→ 1667-01-01 .. 1912-05-31{1912-03..1912-05}→ 1912-03-01 .. 1912-05-31The four failed before the change; with it the suite gives
290 passed, 22 deselected(286 before), andruff checkandruff format --checkpass on the changed files.