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

gh-91928: Add datetime.UTC alias for datetime.timezone.utc #91973

Merged
merged 8 commits into from May 3, 2022

Conversation

Kab1r
Copy link
Contributor

@Kab1r Kab1r commented Apr 27, 2022

fixes #91928

UTC is now module attribute aliased to datetime.timezone.utc.
You can now do the following:

from datetime import UTC

Automerge-Triggered-By: GH:pganssle

@Kab1r Kab1r requested review from pganssle and abalkin as code owners Apr 27, 2022
@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Apr 27, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

bedevere-bot commented Apr 27, 2022

Every change to Python requires a NEWS entry.

Please, add it using the blurb_it Web app or the blurb command-line tool.

Copy link
Member

@pganssle pganssle left a comment

This looks great, thanks!

In addition to my other comments, two other things:

  1. As I believe you are a first-time contributor, you should probably add your name to Misc/ACKS.
  2. Maybe add a very simple test to TestModule, like this:
def test_utc_alias(self):
    self.assertIs(UTC, timezone.utc)

Thanks for your contribution!

Doc/library/datetime.rst Outdated Show resolved Hide resolved
Doc/library/datetime.rst Show resolved Hide resolved
@bedevere-bot
Copy link

bedevere-bot commented Apr 27, 2022

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Kab1r
Copy link
Contributor Author

Kab1r commented Apr 27, 2022

I have made the requested changes; please review again

@bedevere-bot
Copy link

bedevere-bot commented Apr 27, 2022

Thanks for making the requested changes!

@pganssle: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from pganssle Apr 27, 2022
Copy link
Member

@pganssle pganssle left a comment

Can you add this test?

Maybe add a very simple test to TestModule, like this:

    def test_utc_alias(self):
       self.assertIs(UTC, timezone.utc)

Doc/library/datetime.rst Show resolved Hide resolved
@bedevere-bot
Copy link

bedevere-bot commented Apr 27, 2022

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Kab1r
Copy link
Contributor Author

Kab1r commented Apr 27, 2022

I had to move the definition of datetime.UTC to the end so that modifications to datetime.timezone.utc doesn't make it a different object.

@Kab1r
Copy link
Contributor Author

Kab1r commented Apr 27, 2022

I have made the requested changes; please review again

@bedevere-bot
Copy link

bedevere-bot commented Apr 27, 2022

Thanks for making the requested changes!

@pganssle: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from pganssle Apr 27, 2022
Kab1r and others added 4 commits May 3, 2022
1. Add UTC definition into C implementation as well (just for
   consistency, there's no particular reason not to simply assign the
   alias in the Python code later).

2. Move `..versionadded` tag into the right place
@pganssle pganssle force-pushed the feat-datetime-utc-alias branch from c097669 to 9542f54 Compare May 3, 2022
@pganssle pganssle added the 🤖 automerge PR will be merged once it's been approved and all CI passed label May 3, 2022
@miss-islington miss-islington merged commit 48c6165 into python:main May 3, 2022
13 checks passed
@pganssle
Copy link
Member

pganssle commented May 3, 2022

Thanks @Kab1r!

Labels
🤖 automerge PR will be merged once it's been approved and all CI passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add datetime.UTC alias for datetime.timezone.utc
4 participants