From 8b3f54633a1a84ca0b5d5f4c86f1723de9bea08a Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 29 Jan 2025 13:19:08 -0500 Subject: [PATCH] Replace UTC with use of timezone.utc for compatibility datetime.UTC was introduced only in 3.11, so type checking which uses 3.9 ATM fails rightfully, as unittesting on 3.9 and 3.10 --- dandi/download.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dandi/download.py b/dandi/download.py index 35bb0e47e..d2e0e3b8c 100644 --- a/dandi/download.py +++ b/dandi/download.py @@ -3,7 +3,7 @@ from collections import Counter, deque from collections.abc import Callable, Iterable, Iterator, Sequence from dataclasses import InitVar, dataclass, field -from datetime import UTC, datetime +from datetime import datetime, timezone from email.utils import parsedate_to_datetime from enum import Enum from functools import partial @@ -1129,7 +1129,7 @@ def _check_if_more_attempts_allowed( # we could parse it and calculate how long to sleep try: retry_after_date = parsedate_to_datetime(retry_after) - current_date = datetime.now(UTC) + current_date = datetime.now(timezone.utc) difference = retry_after_date - current_date sleep_amount = int(difference.total_seconds()) if sleep_amount < 0: