healthjoy / async-firebase

The lightweight asynchronous client that makes interaction with Firebase Cloud Messaging oversimplified.
MIT License
36 stars 14 forks source link

Python 3.12 deprecated usage of `datetime.utcnow()` #88

Open igoras1993 opened 2 months ago

igoras1993 commented 2 months ago

Describe the bug Python 3.12 deprecated usage of datetime.utcnow():

datetime: datetime.datetime’s utcnow() and utcfromtimestamp() are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call now() and fromtimestamp() with the tz parameter set to datetime.UTC. (Contributed by Paul Ganssle in gh-103857.)

It may be a good idea to use tz-aware datetimes now.

To Reproduce E.g. run AsyncFirebaseClient.build_apns_config(...)

.venv/lib/python3.12/site-packages/async_firebase/client.py:232: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    "apns-expiration": str(int(datetime.utcnow().timestamp()) + ttl),

Expected behavior No warnings are logged.

Desktop:

Smartphone:

igoras1993 commented 2 months ago

Me / my colleagues can help and submit a PR in near future :)