Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit f891932

Browse files
committed
Fix typing for python3.7
1 parent aa4b5da commit f891932

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

synapse/replication/tcp/external_sharded_cache.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import logging
1717
import pickle
1818
from collections import defaultdict
19-
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union
19+
from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Union
2020

2121
import jump
2222
from prometheus_client import Counter, Histogram
@@ -104,7 +104,7 @@ def is_enabled(self) -> bool:
104104
async def mset(
105105
self,
106106
cache_name: str,
107-
values: dict[str, Any],
107+
values: Dict[str, Any],
108108
) -> None:
109109
"""Add the key/value combinations to the named cache, with the expiry time given."""
110110

@@ -115,7 +115,7 @@ async def mset(
115115

116116
logger.debug("Caching %s: %r", cache_name, values)
117117

118-
shard_id_to_encoded_values: dict[int, dict[str, Any]] = defaultdict(dict)
118+
shard_id_to_encoded_values: Dict[int, Dict[str, Any]] = defaultdict(dict)
119119

120120
for key, value in values.items():
121121
redis_key = self._get_redis_key(cache_name, key)
@@ -139,11 +139,11 @@ async def set(self, cache_name: str, key: str, value: Any) -> None:
139139
await self.mset(cache_name, {key: value})
140140

141141
async def _mget_shard(
142-
self, shard_id: int, key_mapping: dict[str, str]
143-
) -> dict[str, Any]:
142+
self, shard_id: int, key_mapping: Dict[str, str]
143+
) -> Dict[str, Any]:
144144
results = await self._redis_shards[shard_id].mget(list(key_mapping.values()))
145145
original_keys = list(key_mapping.keys())
146-
mapped_results: dict[str, Any] = {}
146+
mapped_results: Dict[str, Any] = {}
147147
for i, result in enumerate(results):
148148
if not result:
149149
continue
@@ -155,13 +155,13 @@ async def _mget_shard(
155155
mapped_results[original_keys[i]] = result
156156
return mapped_results
157157

158-
async def mget(self, cache_name: str, keys: Iterable[str]) -> dict[str, Any]:
158+
async def mget(self, cache_name: str, keys: Iterable[str]) -> Dict[str, Any]:
159159
"""Look up a key/value combinations in the named cache."""
160160

161161
if not self.is_enabled():
162162
return {}
163163

164-
shard_id_to_key_mapping: dict[int, dict[str, str]] = defaultdict(dict)
164+
shard_id_to_key_mapping: Dict[int, Dict[str, str]] = defaultdict(dict)
165165

166166
for key in keys:
167167
redis_key = self._get_redis_key(cache_name, key)
@@ -178,14 +178,14 @@ async def mget(self, cache_name: str, keys: Iterable[str]) -> dict[str, Any]:
178178
for shard_id, keys in shard_id_to_key_mapping.items()
179179
]
180180
results: Union[
181-
list, list[dict[str, Any]]
181+
list, list[Dict[str, Any]]
182182
] = await make_deferred_yieldable(
183183
defer.gatherResults(deferreds, consumeErrors=True)
184184
).addErrback(
185185
unwrapFirstError
186186
)
187187

188-
combined_results: dict[str, Any] = {}
188+
combined_results: Dict[str, Any] = {}
189189
for result in results:
190190
combined_results.update(result)
191191

0 commit comments

Comments
 (0)