@@ -115,9 +115,9 @@ async def query_devices(
115115 the number of in-flight queries at a time.
116116 """
117117 with await self ._query_devices_linearizer .queue ((from_user_id , from_device_id )):
118- device_keys_query = query_body .get (
118+ device_keys_query : Dict [ str , Iterable [ str ]] = query_body .get (
119119 "device_keys" , {}
120- ) # type: Dict[str, Iterable[str]]
120+ )
121121
122122 # separate users by domain.
123123 # make a map from domain to user_id to device_ids
@@ -136,7 +136,7 @@ async def query_devices(
136136
137137 # First get local devices.
138138 # A map of destination -> failure response.
139- failures = {} # type : Dict[str, JsonDict]
139+ failures : Dict [str , JsonDict ] = {}
140140 results = {}
141141 if local_query :
142142 local_result = await self .query_local_devices (local_query )
@@ -151,11 +151,9 @@ async def query_devices(
151151
152152 # Now attempt to get any remote devices from our local cache.
153153 # A map of destination -> user ID -> device IDs.
154- remote_queries_not_in_cache = (
155- {}
156- ) # type: Dict[str, Dict[str, Iterable[str]]]
154+ remote_queries_not_in_cache : Dict [str , Dict [str , Iterable [str ]]] = {}
157155 if remote_queries :
158- query_list = [] # type : List[Tuple[str, Optional[str]]]
156+ query_list : List [Tuple [str , Optional [str ]]] = [ ]
159157 for user_id , device_ids in remote_queries .items ():
160158 if device_ids :
161159 query_list .extend (
@@ -362,9 +360,9 @@ async def query_local_devices(
362360 A map from user_id -> device_id -> device details
363361 """
364362 set_tag ("local_query" , query )
365- local_query = [] # type : List[Tuple[str, Optional[str]]]
363+ local_query : List [Tuple [str , Optional [str ]]] = [ ]
366364
367- result_dict = {} # type : Dict[str, Dict[str, dict]]
365+ result_dict : Dict [str , Dict [str , dict ]] = {}
368366 for user_id , device_ids in query .items ():
369367 # we use UserID.from_string to catch invalid user ids
370368 if not self .is_mine (UserID .from_string (user_id )):
@@ -402,9 +400,9 @@ async def on_federation_query_client_keys(
402400 self , query_body : Dict [str , Dict [str , Optional [List [str ]]]]
403401 ) -> JsonDict :
404402 """Handle a device key query from a federated server"""
405- device_keys_query = query_body .get (
403+ device_keys_query : Dict [ str , Optional [ List [ str ]]] = query_body .get (
406404 "device_keys" , {}
407- ) # type: Dict[str, Optional[List[str]]]
405+ )
408406 res = await self .query_local_devices (device_keys_query )
409407 ret = {"device_keys" : res }
410408
@@ -421,8 +419,8 @@ async def on_federation_query_client_keys(
421419 async def claim_one_time_keys (
422420 self , query : Dict [str , Dict [str , Dict [str , str ]]], timeout : int
423421 ) -> JsonDict :
424- local_query = [] # type : List[Tuple[str, str, str]]
425- remote_queries = {} # type : Dict[str, Dict[str, Dict[str, str]]]
422+ local_query : List [Tuple [str , str , str ]] = [ ]
423+ remote_queries : Dict [str , Dict [str , Dict [str , str ]]] = {}
426424
427425 for user_id , one_time_keys in query .get ("one_time_keys" , {}).items ():
428426 # we use UserID.from_string to catch invalid user ids
@@ -439,8 +437,8 @@ async def claim_one_time_keys(
439437 results = await self .store .claim_e2e_one_time_keys (local_query )
440438
441439 # A map of user ID -> device ID -> key ID -> key.
442- json_result = {} # type : Dict[str, Dict[str, Dict[str, JsonDict]]]
443- failures = {} # type : Dict[str, JsonDict]
440+ json_result : Dict [str , Dict [str , Dict [str , JsonDict ]]] = {}
441+ failures : Dict [str , JsonDict ] = {}
444442 for user_id , device_keys in results .items ():
445443 for device_id , keys in device_keys .items ():
446444 for key_id , json_str in keys .items ():
@@ -768,8 +766,8 @@ async def _process_self_signatures(
768766 Raises:
769767 SynapseError: if the input is malformed
770768 """
771- signature_list = [] # type: List[SignatureListItem ]
772- failures = {} # type : Dict[str, Dict[str, JsonDict]]
769+ signature_list : List [ "SignatureListItem" ] = [ ]
770+ failures : Dict [str , Dict [str , JsonDict ]] = {}
773771 if not signatures :
774772 return signature_list , failures
775773
@@ -930,8 +928,8 @@ async def _process_other_signatures(
930928 Raises:
931929 SynapseError: if the input is malformed
932930 """
933- signature_list = [] # type: List[SignatureListItem ]
934- failures = {} # type : Dict[str, Dict[str, JsonDict]]
931+ signature_list : List [ "SignatureListItem" ] = [ ]
932+ failures : Dict [str , Dict [str , JsonDict ]] = {}
935933 if not signatures :
936934 return signature_list , failures
937935
@@ -1300,7 +1298,7 @@ def __init__(self, hs: "HomeServer", e2e_keys_handler: E2eKeysHandler):
13001298 self ._remote_edu_linearizer = Linearizer (name = "remote_signing_key" )
13011299
13021300 # user_id -> list of updates waiting to be handled.
1303- self ._pending_updates = {} # type : Dict[str, List[Tuple[JsonDict, JsonDict]]]
1301+ self ._pending_updates : Dict [str , List [Tuple [JsonDict , JsonDict ]]] = {}
13041302
13051303 async def incoming_signing_key_update (
13061304 self , origin : str , edu_content : JsonDict
@@ -1349,7 +1347,7 @@ async def _handle_signing_key_updates(self, user_id: str) -> None:
13491347 # This can happen since we batch updates
13501348 return
13511349
1352- device_ids = [] # type: List[str ]
1350+ device_ids : List [ str ] = [ ]
13531351
13541352 logger .info ("pending updates: %r" , pending_updates )
13551353
0 commit comments