Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1389 +/- ##
==========================================
- Coverage 99.09% 99.02% -0.08%
==========================================
Files 239 239
Lines 3988 3991 +3
==========================================
Hits 3952 3952
- Misses 36 39 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
serhii73
left a comment
There was a problem hiding this comment.
Code review (claude code-review, at c627f48). I'm not adding my approval yet:
- Conflicts with master. GitHub reports the PR as conflicting. The hunk in
parse_with_formatsrewrites lines master has since changed: master usesnow = settings.RELATIVE_BASE or _now(settings)and a"year" in _missingcheck, not the"%y" in date_format or "%Y" in date_formatstring check. Resolving the conflict mechanically would bring the old check and the UTCnowback. On the new base the fix would beif "year" in _missing: date_obj = date_obj.replace(year=now.year)before the day/month fill. - Related spots left out.
set_correct_day_from_settingsandset_correct_month_from_settingsstill default todatetime.now(), so withRELATIVE_BASEset andPREFER_DAY_OF_MONTH='current'orPREFER_MONTH_OF_YEAR='current', the reference year is mixed with today's day or month. - Leap day. For
%d %Bwith 29 February and a non-leap reference year,date_obj.replace(year=now.year)raises an uncaughtValueError. This already happens today, but since the year replacement is moving, a guard and a test would fit here. - Tests. The test covers only
%BwithPREFER_DAY_OF_MONTH='last'. Please add thefirst/currentpreferences, a format without month and day, and a run withoutRELATIVE_BASE.
03963a8 to
91c931a
Compare
|
@serhii73 Thanks for the detailed review. I rebased the final patch onto current master at |
Avoid requiring the optional US/Eastern backward-compatibility alias in system tzdata. America/New_York preserves the intended Eastern daylight time conversion without adding a dependency or changing parser behavior.
Upstream scrapinghub#1550 independently selected the same canonical timezone. Drop the explanatory comment to avoid a needless overlapping-hunk conflict with that change; test behavior is unchanged.
|
I addressed the review points on head |
serhii73
left a comment
There was a problem hiding this comment.
Thanks for addressing the earlier review, LGTM.
Non-blocking: now and _get_missing_parts() now run once for every format that is tried, so a long date_formats list with a non-UTC TIMEZONE gets noticeably slower; computing now once before the loop would avoid that.
Custom formats that omit the year can choose February's last day using strptime's default year. With a leap-year reference date,
PREFER_DAY_OF_MONTH='last'then returns February 28 instead of February 29. Thecurrentday and month preferences can also mixRELATIVE_BASEwith today's date.Use the same reference date for the year, month, and day defaults. Apply its year before parsing yearless day formats and filling missing components, and skip invalid leap-day dates instead of raising
ValueError. Add coverage for first/current/last preferences, a year-only format, leap and non-leap reference years, and parsing withoutRELATIVE_BASE.Rebased onto current master (
4c4c5e5) and validated head91c931aon Ubuntu with Python 3.14.4:git diff --checkpass.The new-head Build, CIFuzz, and CodSpeed workflows await maintainer approval.