diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py index 36c6627b4c1b..1f4902bc214b 100644 --- a/synapse/util/caches/descriptors.py +++ b/synapse/util/caches/descriptors.py @@ -21,6 +21,7 @@ Awaitable, Callable, Collection, + Coroutine, Dict, Generic, Hashable, @@ -58,7 +59,7 @@ class CachedFunction(Generic[F]): - invalidate: Callable[[Tuple[Any, ...]], None] + invalidate: Callable[[Tuple[Any, ...]], Union[None, Coroutine]] invalidate_all: Callable[[], None] invalidate_external: Any = None prefill: Callable[[Tuple[Any, ...], Any], None] diff --git a/synapse/util/caches/redis_caches.py b/synapse/util/caches/redis_caches.py index fa77fd1776fd..d6ae353aa786 100644 --- a/synapse/util/caches/redis_caches.py +++ b/synapse/util/caches/redis_caches.py @@ -8,6 +8,7 @@ Generic, List, Optional, + Tuple, Union, cast, ) @@ -75,7 +76,7 @@ async def _wrapped(self: Any, *args: Any, **kwargs: Any) -> Any: await redis_shard_cache.set(cache_name, cache_key, value) return value - async def _invalidate(key: KT) -> None: + async def _invalidate(key: Tuple[Any, ...]) -> None: return await redis_shard_cache.delete( cache_name, _redis_key(key), diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py index c30356ebbc34..234f8bf537ce 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py @@ -138,7 +138,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase): """Tests the RegistrationHandler.""" def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: - reactor.advance(1) + reactor.advance(1) # type: ignore hs_config = self.default_config() # some of the tests rely on us having a user consent version