-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-81148: Eliminate unnecessary check in _strptime when determining AM/PM #13428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ade347d
bpo-36967: Eliminate unnecessary check in _strptime when determining …
GPHemsley 4dbc38d
Pauls suggestion to refactor test
StanFromIreland 127d100
Merge branch 'main' into strptime-am-pm
StanFromIreland f6fc0c5
Fix test
StanFromIreland fc87e65
Merge branch 'main' into strptime-am-pm
pganssle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is I think too long for PEP8. If I may suggest a refactoring for this function that I think makes it a bit cleaner:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I likely opted to ignore line length, since much of the rest of the file has PEP8 issues, but I can change that.
Out of curiosity, why do you feel that using
dt.replaceis cleaner than generating a new datetime value directly each iteration?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically
replacedoes generate a new value every iteration (datetimeis immutable), but I get what you mean. I mainly thought it was more readable because:time.strftimeinterface to be a bit more "low level" and harder to read than anstrftimecall on adatetimeobject.replace(hour=hour)makes it more obvious that we didn't have any sort of off-by-one error when constructing the time tuple - it would be hard to notice in a tuple if you were actually cycling through different values for the minute instead of hour.