summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-10-16 16:21:43 +0100
committerRichard van der Hoff <richard@matrix.org>2020-10-16 16:25:15 +0100
commit6d7b22041ddf5ecceaf230404ef00c4d0b432727 (patch)
tree4a5bfaa911595f6513c166bc4c624ff007bdfa8f /synapse/util
parentApply suggestions from code review (diff)
downloadsynapse-6d7b22041ddf5ecceaf230404ef00c4d0b432727.tar.xz
review comments
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/caches/lrucache.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index 1a2c2d4c0b..4e95dd9bf3 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -34,11 +34,16 @@ from synapse.config import cache as cache_config
 from synapse.util.caches import CacheMetric, register_cache
 from synapse.util.caches.treecache import TreeCache
 
-T = TypeVar("T")
+# Function type: the type used for invalidation callbacks
 FT = TypeVar("FT", bound=Callable[..., Any])
+
+# Key and Value type for the cache
 KT = TypeVar("KT")
 VT = TypeVar("VT")
 
+# a general type var, distinct from either KT or VT
+T = TypeVar("T")
+
 
 def enumerate_leaves(node, depth):
     if depth == 0:
@@ -227,7 +232,7 @@ class LruCache(Generic[KT, VT]):
         @synchronized
         def cache_get(
             key: KT,
-            default=None,
+            default: Optional[T] = None,
             callbacks: Iterable[Callable[[], None]] = [],
             update_metrics: bool = True,
         ):
@@ -291,7 +296,7 @@ class LruCache(Generic[KT, VT]):
             ...
 
         @synchronized
-        def cache_pop(key: KT, default=None):
+        def cache_pop(key: KT, default: Optional[T] = None):
             node = cache.get(key, None)
             if node:
                 delete_node(node)