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

Stop using datetime.utcnow() to fix warning #1406

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yuvipanda
Copy link
Collaborator

/Users/yuvipanda/code/repo2docker/./repo2docker/buildpacks/conda/freeze.py:101: 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).

```
/Users/yuvipanda/code/repo2docker/./repo2docker/buildpacks/conda/freeze.py:101: 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).
```
@yuvipanda yuvipanda requested a review from manics February 9, 2025 21:07
@yuvipanda yuvipanda requested a review from minrk February 9, 2025 21:07
@@ -12,7 +12,7 @@
import os
import pathlib
from argparse import ArgumentParser
from datetime import datetime
from datetime import UTC, datetime
Copy link
Member

Choose a reason for hiding this comment

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

This is datetime.timezone.UTC. And timezone.UTC is a class attribute, so not directly importable which means you have to do something like

Suggested change
from datetime import UTC, datetime
from datetime import datetime, timezone
UTC = timezone.UTC

if you want UTC as a top-level variable.

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