Repository navigation
Fix CLI offset bug - #295
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the CLI offset parsing fix.
No open issues 🎉
What changed in this PR
This PR addresses a CLI offset bug by removing ISO 8601 formats from DateTimeOperator’s fallback parsing formats and updating its tests.
Changes:
- Retains only ctime and Unix
dateformats inPARSE_FORMATS. - Converts datetime operator tests to parametrized pytest functions and adds a year-only time-point difference case.
| File | Description |
|---|---|
metomi/isodatetime/tests/test_datetimeoper.py |
Migrates tests to pytest and adds coverage for year-only input. |
metomi/isodatetime/datetimeoper.py |
Removes ISO 8601 fallback formats, makes the format collection a tuple, and simplifies the class declaration. |
Review effort: Balanced
683f45e to
3dc8ca3
Compare
6f4214e to
2db784b
Compare
| "%Y-%m-%dT%H:%M:%S", # ISO8601, extended | ||
| "%Y%m%dT%H%M%S", # ISO8601, basic |
There was a problem hiding this comment.
These two shouldn't be needed, because if strptime fails on all of these formats, it tries the time point parser instead which covers these formats anyway.
isodatetime/metomi/isodatetime/datetimeoper.py
Lines 135 to 144 in 2db784b
The bug came from strptime and the ...%H%M%S format - it considers 0050 to be 0 hours, 5 mins, 0 secs.
samuel-denton
left a comment
There was a problem hiding this comment.
LGTM, repro and test both pass on this branch and fail on master.
|
One review ok here? Small change but potentially big impact if it's wrong I guess. |
|
I'm confident with a single review (plus Copilot) for this one (2 in an ideal world, but we're too stretched to give every PR 2 reviews at the moment) |
Repro
Expected behaviour