Add type hints for most HomeServer parameters (#11095)

This commit is contained in:
Sean Quah 2021-10-22 18:15:41 +01:00 committed by GitHub
parent b9ce53e878
commit 2b82ec425f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 342 additions and 143 deletions

View file

@ -21,6 +21,8 @@ from synapse.logging.context import make_deferred_yieldable
from synapse.util import json_decoder, json_encoder
if TYPE_CHECKING:
from txredisapi import RedisProtocol
from synapse.server import HomeServer
set_counter = Counter(
@ -59,7 +61,12 @@ class ExternalCache:
"""
def __init__(self, hs: "HomeServer"):
self._redis_connection = hs.get_outbound_redis_connection()
if hs.config.redis.redis_enabled:
self._redis_connection: Optional[
"RedisProtocol"
] = hs.get_outbound_redis_connection()
else:
self._redis_connection = None
def _get_redis_key(self, cache_name: str, key: str) -> str:
return "cache_v1:%s:%s" % (cache_name, key)