#542 Fix datetime.utcnow deprecation warning
Merged by onosek. Opened by dherrera.
dherrera/fedpkg datetime-deprecation  into  master

Download 542.patch

Replaces datetime.utcnow() with datetime.now(timezone.utc).replace(tzinfo=None) to replace the deprecated function[0] and keep the current code behaviour.

I decided to use .replace(tzinfo=None) and leave the date variables "timezone naive" to maintain compatibility with the rest of the variables. Another option was to change other variables to be "timezone aware", but external communication already uses datetime objects without timezone information. changing this would mean changing some tests too.

This reduces the number of warnings on py312 from 47 to 5.

[0] https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

@onosek would you mind taking a look at this PR and providing feedback?

Is there anyone available to review this pull request?

rebased onto a5eb5fbe929b71b02f730c645b47d33e2efa2195

So far I can see the issue, that importing timezone fails on ancient python2.7, which was still used by fedpkg on epel7.

Based on the discussion here https://pagure.io/epel/issue/238
I could drop python2.7 support soon/now.

rebased onto 9cb735abebe179e9134d7334a604effd43d89c33

With merged https://pagure.io/fedpkg/pull-request/547
tests pass and I can accept it. Thanks.

Pull-Request has been merged by onosek

Metadata