diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 204f4788bf..c95473134d 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -8,7 +8,7 @@ import re import sys import time import traceback -from functools import wraps +from functools import lru_cache, wraps from typing import ( TYPE_CHECKING, Any, @@ -29,7 +29,6 @@ from django.core.cache import caches from django.core.cache.backends.base import BaseCache from django.db.models import Q from django.http import HttpRequest -from django.utils.lru_cache import lru_cache from zerver.lib.utils import make_safe_digest, statsd, statsd_key @@ -669,7 +668,9 @@ def ignore_unhashable_lru_cache(maxsize: int=128, typed: bool=False) -> DECORATO # In the development environment, we want every file # change to refresh the source files from disk. return user_function - cache_enabled_user_function = internal_decorator(user_function) + + # Casting to Any since we're about to monkey-patch this. + cache_enabled_user_function = cast(Any, internal_decorator(user_function)) def wrapper(*args: Any, **kwargs: Any) -> Any: if not hasattr(cache_enabled_user_function, 'key_prefix'): diff --git a/zerver/lib/i18n.py b/zerver/lib/i18n.py index 66c4bae272..9c6d33c0a1 100644 --- a/zerver/lib/i18n.py +++ b/zerver/lib/i18n.py @@ -1,13 +1,13 @@ import logging import operator import os +from functools import lru_cache from itertools import zip_longest from typing import Any, Dict, List import orjson from django.conf import settings from django.utils import translation -from django.utils.lru_cache import lru_cache from django.utils.translation import ugettext as _