botocore
botocore copied to clipboard
Fix datetime deprecation warning
When running boto3 on Python 3.12 environment, there is a deprecation warning "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)". This PR tries to address this issue.
I've already opened a PR to address this: #3239.
The method used in this PR has been previously attempted, but had to be discarded because it made the datetime objects timezone-aware.
In addition, the datetime.UTC alias used in this PR is only available in Python 3.11 and higher, and would cause AttributeErrors in lower Python versions.
Understandable. Can you please share a solution for this?
PR #3239 is the solution. Unfortunately, the maintainers of botocore have not reviewed and merged the PR yet.
You can suppress the warnings by configuring Python and/or pytest warnings. I recommend searching for "python suppress warnings" and "pytest suppress warnings", depending on your needs.
Thanks a lot!
I'd appreciate this as well!
Resolving in favor of https://github.com/boto/botocore/pull/3239. Thanks for the contribution though!