Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datetime deprecation warning #3372

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

bubai2000
Copy link

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.

@kurtmckee
Copy link

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.

@bubai2000
Copy link
Author

Understandable. Can you please share a solution for this?

@kurtmckee
Copy link

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.

@bubai2000
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants