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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions repo2docker/buildpacks/conda/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

from subprocess import check_call

from ruamel.yaml import YAML
Expand Down Expand Up @@ -68,7 +68,7 @@ def freeze(env_file, frozen_file, platform="linux-64"):
f.write(
f"# AUTO GENERATED FROM {env_file.relative_to(HERE)}, DO NOT MANUALLY MODIFY\n"
)
f.write(f"# Frozen on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
f.write(f"# Frozen on {datetime.now(UTC):%Y-%m-%d %H:%M:%S UTC}\n")
with frozen_tempfile.open() as temp:
f.write(temp.read())

Expand Down Expand Up @@ -98,7 +98,7 @@ def set_python(py_env_file, py):
f.write(
f"# AUTO GENERATED FROM {ENV_FILE.relative_to(HERE)}, DO NOT MANUALLY MODIFY\n"
)
f.write(f"# Generated on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
f.write(f"# Generated on {datetime.now(UTC):%Y-%m-%d %H:%M:%S UTC}\n")
yaml.dump(env, f)


Expand Down
Loading