You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
isoparse docstring says an ISO week without a day "defaults to 0", but the day is 1 (Monday) and 0 is rejected #1629
Versions tested: python-dateutil 3.0.0 from PyPI (the newest release on 2026-10-22; wheel sha256 3c79630202e4152c6add678446984236efe4f57e84d8e892aab0637bab82e9fd) and the master branch at 10f317fde11ce5bc6540e83f896af10e67d52937 (its head on 2026-10-22; the text of src/dateutil/parser/isoparser.py is identical in the 3.0.0 wheel); CPython 3.11.10 on Linux x86_64.
Expected: the docstring of isoparse (rendered on the "parser" page of the documentation) lists, under "Uncommon" date formats:
YYYY-Www or YYYYWww - ISO week (day defaults to 0)
and says a few lines later that "The ISO week and day numbering follows the same logic as datetime.date.isocalendar". In that numbering the weekday runs from 1 (Monday) to 7 (Sunday), and the next bullet (YYYY-Www-D) takes D in that range. So a reader expects either that the default day is a valid ISO day, or that the text says which day it is.
The default is ISO day 1 (Monday): YYYY-Www equals YYYY-Www-1, and src/dateutil/parser/isoparser.py has dayno = 1 in _parse_isodate_uncommon (line 269). Day 0 is rejected, by the code (_calculate_weekdate documents "range is [1 (MON), 7 (SUN)]") and by the test suite (('2012-W01-0', ValueError) in tests/test_isoparser.py); test_isoweek expects 2020-W01 to be 2019-12-30, a Monday. The behaviour looks right; the sentence "day defaults to 0" is the part that is wrong, or at best ambiguous (0 would be Monday only in date.weekday() numbering, which this docstring does not use).
Suggested wording, if useful: "ISO week (day defaults to 1, Monday)".
We have not looked for anything beyond the docstring; the code and tests agree with each other.
Found by running isoparse on generated valid ISO 8601 strings against an independent model and reading its documentation claims one by one.
Opened a PR for this: #1681 — it fixes the isoparse docstring (an ISO week without a day defaults to day 1, Monday, not 0). Changelog fragment added to the PR branch.
Activity
FullStraing commentedon Nov 20, 2026
Opened PR #1681 fixing the docstring — an ISO week without a day defaults to day 1 (Monday).
FullStraing commentedon Nov 20, 2026
Opened a PR for this: #1681 — it fixes the isoparse docstring (an ISO week without a day defaults to day 1, Monday, not 0). Changelog fragment added to the PR branch.