mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
cache: Used lru_cache from functools instead of django.utils.lru_cache.
Django 3.0 removed private Python 2 compatibility APIs so used lru_cache() directly from functools. We cast lru_cache to Any to avoid attr-defined error in mypy since we are adding extra field, 'key_prefix', to this object later.
This commit is contained in:
@@ -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'):
|
||||
|
||||
@@ -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 _
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user