Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
[x] 🧪 Added tests for changed code.
[x] 🛠️ All tests pass when run locally (run tox or make test to find out!).
[x] 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
[ ] 📚 Updated documentation for changed code.
[x] ⏩ Code is up-to-date with the master branch.
If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!
Description of Changes
Python has raised deprecation warning for the use of datetime.datetime.utcnow(). The suggestion is to use datetime.datetime.now(datetime.UTC) or similar.
This PR addresses just by swapping out all datetime utcnow() calls.
I don't think there's anything in documentation to be updated.
With the example raised in #1178 with humanize():
Python 3.12:
Python 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> time = arrow.utcnow()
>>> time.humanize()
'just now'
>>>
No more deprecation warning.
This also works with other python versions, like python 3.11:
Python 3.11.9 (main, Apr 2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> time = arrow.utcnow()
>>> time.humanize()
'just now'
>>> time
<Arrow [2024-08-07T02:20:54.376543+00:00]>
>>>
One thing to note as I setup virtualenv for this:
Despite being listed in requirements.txt, python-dateutil wasn't installed with make build. I had to manually install it.
Pull Request Checklist
Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
tox
ormake test
to find out!).tox -e lint
ormake lint
to find out!).master
branch.If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!
Description of Changes
Python has raised deprecation warning for the use of
datetime.datetime.utcnow()
. The suggestion is to usedatetime.datetime.now(datetime.UTC)
or similar.This PR addresses just by swapping out all datetime utcnow() calls. I don't think there's anything in documentation to be updated.
With the example raised in #1178 with
humanize()
:Python 3.12:
No more deprecation warning.
This also works with other python versions, like python 3.11:
One thing to note as I setup
virtualenv
for this: Despite being listed in requirements.txt,python-dateutil
wasn't installed withmake build
. I had to manually install it.But that's a different thing to this PR.
Closes https://github.com/arrow-py/arrow/issues/1178