diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index fdfe5206ed..2124224b8d 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -19,6 +19,8 @@ from datetime import datetime, timedelta from typing import IO, Any, Dict, List, Optional, Sequence, Set, Union, overload from urllib.parse import SplitResult +import zoneinfo + DEPLOYMENTS_DIR = "/home/zulip/deployments" LOCK_DIR = os.path.join(DEPLOYMENTS_DIR, "lock") TIMESTAMP_FORMAT = "%Y-%m-%d-%H-%M-%S" @@ -470,11 +472,6 @@ def os_families() -> Set[str]: def get_tzdata_zi() -> IO[str]: - if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo - else: # nocoverage - import zoneinfo - for path in zoneinfo.TZPATH: filename = os.path.join(path, "tzdata.zi") if os.path.exists(filename): diff --git a/tools/setup/build_timezone_values b/tools/setup/build_timezone_values index ece4037b42..29bbde95f3 100755 --- a/tools/setup/build_timezone_values +++ b/tools/setup/build_timezone_values @@ -3,10 +3,7 @@ import json import os import sys -if sys.version_info < (3, 9): - from backports import zoneinfo -else: - import zoneinfo +import zoneinfo ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../") sys.path.insert(0, ZULIP_PATH) diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py index e51b3b6d14..1af03824b7 100644 --- a/zerver/lib/email_notifications.py +++ b/zerver/lib/email_notifications.py @@ -12,6 +12,7 @@ from email.headerregistry import Address from typing import Any, Dict, List, Optional, Tuple, Union import lxml.html +import zoneinfo from bs4 import BeautifulSoup from django.conf import settings from django.contrib.auth import get_backends @@ -42,11 +43,6 @@ from zerver.models.messages import get_context_for_message from zerver.models.scheduled_jobs import NotificationTriggers from zerver.models.users import get_user_profile_by_id -if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo -else: # nocoverage - import zoneinfo - logger = logging.getLogger(__name__) diff --git a/zerver/lib/validator.py b/zerver/lib/validator.py index 16200df654..f2015d58b1 100644 --- a/zerver/lib/validator.py +++ b/zerver/lib/validator.py @@ -29,7 +29,6 @@ for any particular type of object. """ import re -import sys from dataclasses import dataclass from datetime import datetime, timezone from decimal import Decimal @@ -52,6 +51,7 @@ from typing import ( ) import orjson +import zoneinfo from django.core.exceptions import ValidationError from django.core.validators import URLValidator, validate_email from django.utils.translation import gettext as _ @@ -63,11 +63,6 @@ from zerver.lib.exceptions import InvalidJSONError, JsonableError from zerver.lib.timezone import canonicalize_timezone from zerver.lib.types import ProfileFieldData, Validator -if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo -else: # nocoverage - import zoneinfo - ResultT = TypeVar("ResultT") diff --git a/zerver/signals.py b/zerver/signals.py index 7418bc4b76..bcabc97821 100644 --- a/zerver/signals.py +++ b/zerver/signals.py @@ -1,6 +1,6 @@ -import sys from typing import Any, Optional +import zoneinfo from django.conf import settings from django.contrib.auth.signals import user_logged_in, user_logged_out from django.dispatch import receiver @@ -14,11 +14,6 @@ from zerver.lib.send_email import FromAddress from zerver.lib.timezone import canonicalize_timezone from zerver.models import UserProfile -if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo -else: # nocoverage - import zoneinfo - JUST_CREATED_THRESHOLD = 60 diff --git a/zerver/tests/test_new_users.py b/zerver/tests/test_new_users.py index afc337f5cb..3ba6c5c2e2 100644 --- a/zerver/tests/test_new_users.py +++ b/zerver/tests/test_new_users.py @@ -1,8 +1,8 @@ -import sys from datetime import datetime, timedelta, timezone from typing import Sequence import time_machine +import zoneinfo from django.conf import settings from django.core import mail from django.test import override_settings @@ -18,11 +18,6 @@ from zerver.models import Message, Realm, Recipient, Stream, UserProfile from zerver.models.realms import get_realm from zerver.signals import JUST_CREATED_THRESHOLD, get_device_browser, get_device_os -if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo -else: # nocoverage - import zoneinfo - class SendLoginEmailTest(ZulipTestCase): """ diff --git a/zerver/tests/test_timezone.py b/zerver/tests/test_timezone.py index 5d89c659c6..8718cc2098 100644 --- a/zerver/tests/test_timezone.py +++ b/zerver/tests/test_timezone.py @@ -1,16 +1,11 @@ -import sys from datetime import datetime, timezone +import zoneinfo from django.utils.timezone import now as timezone_now from zerver.lib.test_classes import ZulipTestCase from zerver.lib.timezone import canonicalize_timezone, common_timezones -if sys.version_info < (3, 9): # nocoverage - from backports import zoneinfo -else: # nocoverage - import zoneinfo - class TimeZoneTest(ZulipTestCase): def test_canonicalize_timezone(self) -> None: