summary refs log tree commit diff
path: root/synapse/util/caches/ttlcache.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2023-09-08 19:29:38 +0100
committerGitHub <noreply@github.com>2023-09-08 19:29:38 +0100
commitedd83f23b710f0caae05d5766b474de3b6f24e9e (patch)
tree91c841f77e186fea9ede52df87d50126541162d1 /synapse/util/caches/ttlcache.py
parent Upgrade CI run of Python 3.12 from rc1 to rc2 (#16280) (diff)
downloadsynapse-edd83f23b710f0caae05d5766b474de3b6f24e9e.tar.xz
Improve type hints for attrs classes (#16276)
Diffstat (limited to '')
-rw-r--r--synapse/util/caches/ttlcache.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/synapse/util/caches/ttlcache.py b/synapse/util/caches/ttlcache.py
index f6b3ee31e4..48a6e4a906 100644
--- a/synapse/util/caches/ttlcache.py
+++ b/synapse/util/caches/ttlcache.py
@@ -35,10 +35,10 @@ class TTLCache(Generic[KT, VT]):
 
     def __init__(self, cache_name: str, timer: Callable[[], float] = time.time):
         # map from key to _CacheEntry
-        self._data: Dict[KT, _CacheEntry] = {}
+        self._data: Dict[KT, _CacheEntry[KT, VT]] = {}
 
         # the _CacheEntries, sorted by expiry time
-        self._expiry_list: SortedList[_CacheEntry] = SortedList()
+        self._expiry_list: SortedList[_CacheEntry[KT, VT]] = SortedList()
 
         self._timer = timer
 
@@ -160,11 +160,11 @@ class TTLCache(Generic[KT, VT]):
 
 
 @attr.s(frozen=True, slots=True, auto_attribs=True)
-class _CacheEntry:  # Should be Generic[KT, VT]. See python-attrs/attrs#313
+class _CacheEntry(Generic[KT, VT]):
     """TTLCache entry"""
 
     # expiry_time is the first attribute, so that entries are sorted by expiry.
     expiry_time: float
     ttl: float
-    key: Any  # should be KT
-    value: Any  # should be VT
+    key: KT
+    value: VT