Replace pendulum with whenever#256
Conversation
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## infrahub-develop #256 +/- ##
===================================================
Coverage ? 70.53%
===================================================
Files ? 81
Lines ? 7561
Branches ? 1469
===================================================
Hits ? 5333
Misses ? 1849
Partials ? 379
Flags with carried forward coverage won't be shown. Click here to find out more.
|
41aa45d to
cceabf0
Compare
cceabf0 to
ce24e52
Compare
ce24e52 to
702a5f1
Compare
8234ed7 to
97986b8
Compare
ogenstad
left a comment
There was a problem hiding this comment.
We should also have a news fragment stating that the installation on Python 3.13 was fixed.
changelog/255.fixed.md
Outdated
| @@ -0,0 +1 @@ | |||
| Refactor Timestamp to use `whenever` instead of `pendulum` and extend Timestamp with add(), subtract(), and to_datetime(). Direct access to `obj` and `add_delta` have been deprecated and will be removed in a future version. No newline at end of file | |||
There was a problem hiding this comment.
I think we could split this up into two fragments where we also use the special one for things marked for deprecation.
There was a problem hiding this comment.
Good point, I forgot about the deprecated section
| UserWarning, | ||
| stacklevel=2, | ||
| ) | ||
| return self._obj |
There was a problem hiding this comment.
I'd suggest creating a follow up issue for when this should be removed and tie it into a future milestone so we know when to remove it.
| return ZonedDateTime.now("UTC").subtract(**params) # type: ignore[call-overload] | ||
|
|
||
| return DateTime.now(tz="UTC").subtract(**params) | ||
| raise TimestampFormatError(f"Invalid time format for {value}") |
There was a problem hiding this comment.
I know it was like this before but I think the error definition should live in exceptions.py like the other core SDK exceptions.
There was a problem hiding this comment.
good point, I moved it
infrahub_sdk/utils.py
Outdated
| except TimestampFormatError: | ||
| return None | ||
|
|
||
| delta: TimeDelta = Timestamp()._obj.difference(time_value._obj) |
There was a problem hiding this comment.
shouldn't these use to_datetime()?
There was a problem hiding this comment.
Not datetime, the goal is to access the ZonedDateTime here
I added a new get_obj() instead of accessing it directly
97986b8 to
d778262
Compare
d778262 to
a2a496f
Compare
fixes #255
This PR replaces
pendulumwithwheneverto manage datetime, mainly as part of the Timestamp class.This change allows us to re-enable the support for Python 3.13, since we haven't shipped a release without 3.13 support, I've updated the changelog for #251
In the process the Timestamp object has been slightly refactored
to_datetime()add_delta()has been deprecated, in favor ofadd()andsubstract()that are more inline withwhenever