Skip to content

Conversation

@nineteendo
Copy link
Contributor

@nineteendo nineteendo commented Jun 20, 2024

It's better to point to datetime.timezone.utc as datetime.UTC was only added in Python 3.11.
No need to suggest to make code backwards incompatible without a good reason.

@pganssle
Copy link
Member

I think I am -0 on this change. I chose the datetime.UTC wording deliberately because it advertises that the datetime.UTC singleton exists, which allows people to do things like from datetime import UTC; datetime.now(UTC) (which is the same number of characters as datetime.utcnow(), which some people care about).

I would not think that we should be so concerned with backwards compatibility, since this deprecation warning only even happens in Python 3.12+, and it's referring to a removal that won't take place for an indefinite amount of time in the future.

Evidently some people are indeed confused by this, though, so I dunno, maybe it's better on net to recommend the wordy version? 🤷

@pganssle pganssle changed the title gh-120784: Fix utc deprecation msg gh-120784: Reword utcnow/utcfromtimestamp deprecation warning to use datetime.timezone.utc Jun 21, 2024
Copy link
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned, I'm not really in favor of merging this, but if we do end up merging it, it should probably get a news blurb.

@bedevere-app
Copy link

bedevere-app bot commented Jun 21, 2024

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.

@nineteendo
Copy link
Contributor Author

nineteendo commented Jun 21, 2024

Ruff also mentions datetime.timezone.utc first:

Would you prefer to mention both too?

@nineteendo
Copy link
Contributor Author

pganssle, I have made the requested changes; please review again.

@bedevere-app
Copy link

bedevere-app bot commented Jun 21, 2024

Thanks for making the requested changes!

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

@merwok
Copy link
Member

merwok commented Sep 12, 2024

I agree with Paul, the warning is not wrong and this is not really a bug.

@merwok merwok closed this Sep 12, 2024
@nineteendo nineteendo deleted the fix-utc-deprecation-msg branch September 12, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants