Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
cache: Remove needless monkey patching.
Anders Kaseorgd5fea08b8ab9
diff --git a/zerver/lib/cache.py b/zerver/lib/cache.pyindex c67bce6de9b..e5b82ae4a6f 100644--- a/zerver/lib/cache.py+++ b/zerver/lib/cache.py@@ -755,21 +755,22 @@ def ignore_unhashable_lru_cache(# change to refresh the source files from disk.return user_function- # Casting to Any since we're about to monkey-patch this.- cache_enabled_user_function: Any = internal_decorator(user_function)+ cache_enabled_user_function = internal_decorator(user_function)+ key_prefix = KEY_PREFIXdef wrapper(*args: ParamT.args, **kwargs: ParamT.kwargs) -> ReturnT:- if not hasattr(cache_enabled_user_function, "key_prefix"):- cache_enabled_user_function.key_prefix = KEY_PREFIX+ nonlocal key_prefix- if cache_enabled_user_function.key_prefix != KEY_PREFIX:+ if key_prefix != KEY_PREFIX:# Clear cache when cache.KEY_PREFIX changes. This is used in# tests.cache_enabled_user_function.cache_clear()- cache_enabled_user_function.key_prefix = KEY_PREFIX+ key_prefix = KEY_PREFIXtry:- return cache_enabled_user_function(*args, **kwargs)+ return cache_enabled_user_function(+ *args, **kwargs # type: ignore[arg-type] # might be unhashable+ )except TypeError:# args or kwargs contains an element which is unhashable. In# this case we don't cache the result.