fix(functions): refuse a time string add_time_to_date cannot read - #6779
Open
chiruu12 wants to merge 1 commit into
Open
fix(functions): refuse a time string add_time_to_date cannot read#6779chiruu12 wants to merge 1 commit into
chiruu12 wants to merge 1 commit into
Conversation
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 #6778
add_time_to_datereads units withre.findall(r"(\d+)([wdhms])", time_str)and adds what it finds. When it finds nothing it adds nothing, so a string it cannot read returns the date unchanged and looks like it worked.This raises instead. The message names the string it could not read and the units it understands.
Nothing that parsed before changes.
1w,2d,3h,30m,45sand1w 2d 3h 30mall still work; the guard fires only when the regex matched nothing at all, which is why the spaced form is unaffected.Tests cover six unreadable spellings, including
1yand3M, which are the units people reach for and neither of which is supported. Three more pin the accepted forms as controls. The six fail on the commit before the fix and the three pass either way.tests/test_functions.py tests/test_iohandler.py: 206 passed.ruff checkclean.I did not add month support.
malready means minutes, so3Mcannot be a month without making the unit ambiguous. This is about the silence, not the unit set.