Remove deprecation warning of the utcnow function#367
Remove deprecation warning of the utcnow function#367wint3ria wants to merge 3 commits intorayference:mainfrom
Conversation
leroyvn
left a comment
There was a problem hiding this comment.
Hi @wint3ria, thanks for your suggestion. I however think that your proposed fix only applies to Python v3.11 and higher: you need to keep the old implementation for older versions.
So my suggestion is this: in a utility module, implement a now() function that conditionally uses the old or new interface depending on Python version. Something like:
import sys
import datetime
if sys.version_info[1] < 10:
def now():
return datetime.datetime.utcnow()
else:
def now():
return datetime.datetime.now(datetime.UTC)|
Thank you for the review. To streamline the work and avoid extra back and forth, I suggest to wait for me to mark the PR as ready. Unless you need this to be done within a specific deadline? As per our last discussion about it, I couldn't find a proper backport, checking the version manually seems then to be the solution, indeed. |
|
The reason to mark the PR as ready to trigger CI, happy to switch it back to draft, of course. No deadline, no. |
For my application I tend to create several atmospheric profiles in distributed batches, and my logs are flooded by this deprecation warning
This simple patch fixes the issue by using the latest API as recommended.