mirror of https://github.com/zulip/zulip.git
cache: Use QuerySetAny for isinstance check.
Previously, `QuerySet` does not support isinstance check since it is defined to be generic in django-stubs. In a recent update, such check is possible by using `QuerySetAny`, a non-generic alias of `QuerySet`. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
f2a20b56bc
commit
24f24d236d
|
@ -569,9 +569,9 @@ django-stubs==1.15.0 \
|
|||
--hash=sha256:0bbf9eb172c5b06eccff2d704c7c3906e4a2c6146df8c32ee9f3a51e29265581 \
|
||||
--hash=sha256:25010658acac0ce4a69211b55dd719fd16dbfe54fcfe5c878d0c8db07bdd5482
|
||||
# via -r requirements/mypy.in
|
||||
django-stubs-ext==0.7.0 \
|
||||
--hash=sha256:4fd8cdbc68d1a421f21bb7e0d9e76d50f6a4b504d350ba786405daf536e90c21 \
|
||||
--hash=sha256:d729fbc7fe8970a7e26b35956c35b48502516f011d523c0577bdfb02ed956284
|
||||
django-stubs-ext==0.8.0 \
|
||||
--hash=sha256:9a9ba9e2808737949de96a0fce8b054f12d38e461011d77ebc074ffe8c43dfcb \
|
||||
--hash=sha256:a454d349d19c26d6c50c4c6dbc1e8af4a9cda4ce1dc4104e3dd4c0330510cc56
|
||||
# via
|
||||
# -r requirements/common.in
|
||||
# django-stubs
|
||||
|
|
|
@ -400,9 +400,9 @@ django-statsd-mozilla==0.4.0 \
|
|||
--hash=sha256:0d87cb63de8107279cbb748caad9aa74c6a44e7e96ccc5dbf07b89f77285a4b8 \
|
||||
--hash=sha256:81084f3d426f5184f0a0f1dbfe035cc26b66f041d2184559d916a228d856f0d3
|
||||
# via -r requirements/common.in
|
||||
django-stubs-ext==0.7.0 \
|
||||
--hash=sha256:4fd8cdbc68d1a421f21bb7e0d9e76d50f6a4b504d350ba786405daf536e90c21 \
|
||||
--hash=sha256:d729fbc7fe8970a7e26b35956c35b48502516f011d523c0577bdfb02ed956284
|
||||
django-stubs-ext==0.8.0 \
|
||||
--hash=sha256:9a9ba9e2808737949de96a0fce8b054f12d38e461011d77ebc074ffe8c43dfcb \
|
||||
--hash=sha256:a454d349d19c26d6c50c4c6dbc1e8af4a9cda4ce1dc4104e3dd4c0330510cc56
|
||||
# via -r requirements/common.in
|
||||
django-two-factor-auth[call,phonenumberslite,sms]==1.15.0 \
|
||||
--hash=sha256:def6b3242cbc53476c06972f1ba5069edd89a94edeb0f2723a6536ff4002dae0 \
|
||||
|
|
|
@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 169
|
|||
# historical commits sharing the same major version, in which case a
|
||||
# minor version bump suffices.
|
||||
|
||||
PROVISION_VERSION = (224, 3)
|
||||
PROVISION_VERSION = (224, 4)
|
||||
|
|
|
@ -25,8 +25,9 @@ from typing import (
|
|||
from django.conf import settings
|
||||
from django.core.cache import caches
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.db.models import Q, QuerySet
|
||||
from django.db.models import Q
|
||||
from django.http import HttpRequest
|
||||
from django_stubs_ext import QuerySetAny
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
from zerver.lib.utils import make_safe_digest, statsd, statsd_key
|
||||
|
@ -167,7 +168,7 @@ def cache_with_key(
|
|||
return val[0]
|
||||
|
||||
val = func(*args, **kwargs)
|
||||
if isinstance(val, QuerySet): # type: ignore[misc] # https://github.com/typeddjango/django-stubs/issues/704
|
||||
if isinstance(val, QuerySetAny):
|
||||
logging.error(
|
||||
"cache_with_key attempted to store a full QuerySet object -- declining to cache",
|
||||
stack_info=True,
|
||||
|
|
Loading…
Reference in New Issue