-
-
Notifications
You must be signed in to change notification settings - Fork 846
Replace deprecated utcnow() with now(UTC) #1097
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Should we mention on the readme that things should be run using Python 3.11? |
Good idea! I removed the bit about a Python needing |
I was taking a break at the time due to PyCon, sorry, but I'm afraid I don't really understand the rationale for requiring the latest upstream Python version released only a few months ago to be able to render the devguide locally. Sure, many folks will have it one way or another, but it's far from a given as it targets contributors of all experience levels (especially newer ones) and those that make non-code contributions, and if they're using the By contrast to how much this is likely to make life harder for many contributors, especially newer ones, it seems easy to avoid this minor issue (a mere warning) all in one line by, e.g., using a ternary conditional: now_str = str(dt.datetime.now(dt.UTC) if sys.version_info > (3, 10) else dt.datetime.utcnow()) Is there something I'm missing here? |
Sure, please see PR #1107. |
Thanks @hugovk , as always! |
datetime.datetime.utcnow
raises a deprecation warning in Python 3.12: python/cpython#103857.datetime.UTC
is new in 3.11, and is an alias ofdatetime.timezone.utc
, but I think we're fine requiring 3.11+ here.https://docs.python.org/3/library/datetime.html#datetime.UTC
📚 Documentation preview 📚: https://cpython-devguide--1097.org.readthedocs.build/