arrow-py/arrow

datetime.utcnow is deprecated

Closed this issue · 1 comments

Python 3.12 deprecates the use of datetime.datetime.utcnow, suggesting instead to use datetime.datetime.now(datetime.UTC).

Example from the humanize method:

  File "/root/project/my_project/libs/utils.py", line 54, in arrow_humanize
    return time.humanize()
           ^^^^^^^^^^^^^^^
  File "/root/project/.tox/py312/lib/python3.12/site-packages/arrow/arrow.py", line 1150, in humanize
    utc = dt_datetime.utcnow().replace(tzinfo=dateutil_tz.tzutc())
          ^^^^^^^^^^^^^^^^^^^^
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).

Mind if I took this on? Seems like a fairly straightforward task to get started?