From b9fdc01ab875b22edd855770c8037a757f0e92a1 Mon Sep 17 00:00:00 2001 From: anthony sottile <103459774+asottile-sentry@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:01:00 -0400 Subject: [PATCH] ref: remove incr_version / decr_version (#15) these methods are unsafe with our usage of cache --- django-stubs/core/cache/backends/base.pyi | 4 ---- scripts/stubtest/allowlist.txt | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi index 91f441f02..46d484a3d 100644 --- a/django-stubs/core/cache/backends/base.pyi +++ b/django-stubs/core/cache/backends/base.pyi @@ -60,10 +60,6 @@ class BaseCache: async def adelete_many(self, keys: Iterable[Any], version: Any | None = None) -> None: ... def clear(self) -> None: ... async def aclear(self) -> None: ... - def incr_version(self, key: Any, delta: int = 1, version: Any | None = None) -> int: ... - async def aincr_version(self, key: Any, delta: int = 1, version: Any | None = None) -> int: ... - def decr_version(self, key: Any, delta: int = 1, version: Any | None = None) -> int: ... - async def adecr_version(self, key: Any, delta: int = 1, version: Any | None = None) -> int: ... def close(self, **kwargs: Any) -> None: ... async def aclose(self, **kwargs: Any) -> None: ... diff --git a/scripts/stubtest/allowlist.txt b/scripts/stubtest/allowlist.txt index 60a68c95b..c1ad9e941 100644 --- a/scripts/stubtest/allowlist.txt +++ b/scripts/stubtest/allowlist.txt @@ -478,3 +478,13 @@ django.contrib.auth.views.UserModel # Using the definitions from `dict` (from typeshed) django.contrib.sessions.backends.base.SessionBase.get django.contrib.sessions.backends.base.SessionBase.setdefault + +# sentry: we remove these methods because they are unsafe for our usage +django.core.cache.BaseCache.adecr_version +django.core.cache.BaseCache.aincr_version +django.core.cache.BaseCache.decr_version +django.core.cache.BaseCache.incr_version +django.core.cache.backends.base.BaseCache.adecr_version +django.core.cache.backends.base.BaseCache.aincr_version +django.core.cache.backends.base.BaseCache.decr_version +django.core.cache.backends.base.BaseCache.incr_version