-
Notifications
You must be signed in to change notification settings - Fork 4
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I forgot about the deprecated section
UserWarning, | ||
stacklevel=2, | ||
) | ||
return self._obj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
|
||
return DateTime.now(tz="UTC").subtract(**params) | ||
raise TimestampFormatError(f"Invalid time format for {value}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these use to_datetime()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
pendulum
withwhenever
to 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