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

Replace deprecated datetime.utcnow() calls #1977

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Replace deprecated datetime.utcnow() calls #1977

merged 2 commits into from
Jul 24, 2024

Conversation

zmc
Copy link
Member

@zmc zmc commented Jul 12, 2024

No description provided.

@zmc zmc marked this pull request as draft July 12, 2024 23:47
@@ -275,7 +275,7 @@ def unlock_targets(job_config):


def run_with_watchdog(process, job_config):
job_start_time = datetime.utcnow()
job_start_time = datetime.datetime.now(datetime.timezone.utc)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks gut, I know it must be the same to use shorter form datetime.UTC, but why did you prefer longer variant, for the reference:

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).

Copy link
Member Author

Choose a reason for hiding this comment

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

Because they didn't make it available as datetime.UTC until 3.11 🙃
https://docs.python.org/3/library/datetime.html#datetime.UTC

@@ -19,6 +19,8 @@ jobs:
python: "3.10"
- os: ubuntu-22.04
python: "3.11"
- os: ubuntu-24.04
python: "3.12"
Copy link
Contributor

Choose a reason for hiding this comment

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

Love it

@zmc zmc force-pushed the utcnow branch 3 times, most recently from 692c49d to 80fb908 Compare July 23, 2024 20:56
@zmc zmc marked this pull request as ready for review July 23, 2024 21:29
@zmc zmc requested a review from kshtsk July 23, 2024 21:30
@zmc zmc merged commit 55b2d2b into main Jul 24, 2024
9 checks passed
@zmc zmc deleted the utcnow branch July 24, 2024 16:49
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