boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.44k stars 1.06k forks source link

Remove datetime.datetime.utcnow #3145

Open azliu0 opened 3 months ago

azliu0 commented 3 months ago

Resolves #3088, which is currently being tracked in boto/boto3#3889.

It looks like this change was attempted in #3003, but was reverted after #3077 in #3004. These changes differ from #3003 by also addressing the conversion issues brought up in #3077, ensuring that all datetime objects are timezone aware.

These changes further improve on the changes in #3003 by mocking out .now with a factory, rather than hard-coding the return to be the utc value only. This is closer to the actual functionality of .now, which is a function that takes timezone as input (but defaults to utc).

All unit and functional tests pass locally, with the exception of functional/test_resource_leaks.py, which does not pass for me locally before the change.

adarshraj007 commented 1 month ago

Is this issue resolved? We are still getting when we upgrade python to 3.12 DeprecationWarning: datetime.datetime.utcnow() is dep recated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). datetime_now = datetime.datetime.utcnow()

TheByronHimes commented 3 weeks ago

It would be wonderful if this could get reviewed and merged. We're getting a mountain of deprecation warnings from our tests because of this. Thanks for the work @azliu0