Skip to content

gh-127553: Remove TODO comment in _pydatetime._isoweek1monday #127564

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 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,10 +2392,11 @@ def __reduce__(self):

def _isoweek1monday(year):
# Helper to calculate the day number of the Monday starting week 1
# XXX This could be done more efficiently
THURSDAY = 3
firstday = _ymd2ord(year, 1, 1)
firstweekday = (firstday + 6) % 7 # See weekday() above
# If the first weekday is after Thursday,
# ISO week 1 doesn't start until the next Monday
Copy link
Member

@picnixz picnixz Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be moved inside the if and I would only keep "ISO week 1 does not start until the next Monday" (or maybe no comment at all). Waiting for Erlend's opinion on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the comment is needed. The code below speaks for itself, IMO. Let's just remove the XXX comment. After all, that is what the PR title says this PR should do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland Got it! I've reverted the change

week1monday = firstday - firstweekday
if firstweekday > THURSDAY:
week1monday += 7
Expand Down
Loading