-
Notifications
You must be signed in to change notification settings - Fork 14
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
DEV: Update API calls to datetime
functionality
#117
Conversation
Seems like the newer API is applicable from Python 3.11 onwards. |
https://github.com/executablebooks/jupyter-cache/actions/runs/10508401592/job/29112220264?pr=117 should pass by re-running. |
Requesting @chrisjsewell @choldgraf @agoose77 for review. Thanks. <3. |
jupyter_cache/cache/db.py
Outdated
def datetime_utcnow(): | ||
if sys.version_info.minor >= 11: | ||
return lambda: datetime.datetime.now(datetime.UTC) | ||
return datetime.datetime.utcnow | ||
|
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 don't think you need to test the version; datetime.datetime.now(...)
works in all versions of Python supported by jupyter-cache
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.
Actually datetime.UTC
is available only in Python >= 3.11. Let me try with datetime.datetime.now()
.
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.
@czgdp1807 ah, try datetime.timezone.utc
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.
Addressed.
for more information, see https://pre-commit.ci
There is a codecov error with Python 3.10 job. |
This is a duplicate of #114. Either way, please let me know how I can help moving a release fwd as I run into these deprecations in a few projects, too. |
Well, the other would have been compatible too two weeks ago if CI was allowed to run on it 🤷♀️ |
Please check the description of this PR. I personally don't know why CI wasn't executed on your PR. Maintainers of this repository can comment on it.
Apologies. Referenced your PR here as well. |
Continues - #114. #114 uses the latest APIs from
datetime
which works with Python >= 3.11. However, one needs to make it work with Python 3.9, Python 3.10 as well. For that one has to usedatetime.timezone.utc
and notdatetime.UTC
(available only in >= 3.11). See the review thread - #117 (comment)The API calls in
main
are depreciated. I have updated these calls to comply with the latest versions. If I usemain
to build SciPy docs withmyst_nb
execution mode set tocache
then I get the following errors,With my PR I get the following,