Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix UP033 Use `@functools.cache`.
Anders Kaseorga82a3eb4d7d7
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 45285e845ce..08ecd64b2e7 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -14,7 +14,7 @@ import subprocessimport tempfilefrom contextlib import suppressfrom datetime import datetime-from functools import lru_cache+from functools import cachefrom typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, Tuple, TypedDictimport orjson@@ -2232,7 +2232,7 @@ def chunkify(lst: List[int], chunk_size: int) -> List[List[int]]:def export_messages_single_user(user_profile: UserProfile, *, output_dir: Path, reaction_message_ids: Set[int]) -> None:- @lru_cache(maxsize=None)+ @cachedef get_recipient(recipient_id: int) -> str:recipient = Recipient.objects.get(id=recipient_id)diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex e43b403b882..85bf6cb06fa 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -7,7 +7,7 @@ import loggingimport refrom dataclasses import dataclassfrom email.headerregistry import Address-from functools import lru_cache+from functools import cachefrom typing import (TYPE_CHECKING,Any,@@ -162,7 +162,7 @@ def has_apns_credentials() -> bool:return settings.APNS_TOKEN_KEY_FILE is not None or settings.APNS_CERT_FILE is not None-@lru_cache(maxsize=None)+@cachedef get_apns_context() -> Optional[APNsContext]:# We lazily do this import as part of optimizing Zulip's base# import time.diff --git a/zerver/lib/timezone.py b/zerver/lib/timezone.pyindex 4b4f3a7b22c..049b8d3fe05 100644--- a/zerver/lib/timezone.py+++ b/zerver/lib/timezone.py@@ -1,10 +1,10 @@-from functools import lru_cache+from functools import cachefrom typing import Dictfrom scripts.lib.zulip_tools import get_tzdata_zi-@lru_cache(maxsize=None)+@cachedef get_canonical_timezone_map() -> Dict[str, str]:canonical = {}with get_tzdata_zi() as f:diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex 8ce520bce9f..601b918d728 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -9,7 +9,7 @@ import tracebackimport uuidfrom collections import dequefrom contextlib import suppress-from functools import lru_cache+from functools import cachefrom typing import (AbstractSet,Any,@@ -1110,7 +1110,7 @@ def process_message_event(recipient_type_name: str = wide_dict["type"]sending_client: str = wide_dict["client"]- @lru_cache(maxsize=None)+ @cachedef get_client_payload(apply_markdown: bool, client_gravatar: bool, can_access_sender: bool) -> Dict[str, Any]: