@@ -115,9 +115,9 @@ async def query_devices(
115
115
the number of in-flight queries at a time.
116
116
"""
117
117
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 (
119
119
"device_keys" , {}
120
- ) # type: Dict[str, Iterable[str]]
120
+ )
121
121
122
122
# separate users by domain.
123
123
# make a map from domain to user_id to device_ids
@@ -136,7 +136,7 @@ async def query_devices(
136
136
137
137
# First get local devices.
138
138
# A map of destination -> failure response.
139
- failures = {} # type : Dict[str, JsonDict]
139
+ failures : Dict [str , JsonDict ] = {}
140
140
results = {}
141
141
if local_query :
142
142
local_result = await self .query_local_devices (local_query )
@@ -151,11 +151,9 @@ async def query_devices(
151
151
152
152
# Now attempt to get any remote devices from our local cache.
153
153
# 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 ]]] = {}
157
155
if remote_queries :
158
- query_list = [] # type : List[Tuple[str, Optional[str]]]
156
+ query_list : List [Tuple [str , Optional [str ]]] = [ ]
159
157
for user_id , device_ids in remote_queries .items ():
160
158
if device_ids :
161
159
query_list .extend (
@@ -362,9 +360,9 @@ async def query_local_devices(
362
360
A map from user_id -> device_id -> device details
363
361
"""
364
362
set_tag ("local_query" , query )
365
- local_query = [] # type : List[Tuple[str, Optional[str]]]
363
+ local_query : List [Tuple [str , Optional [str ]]] = [ ]
366
364
367
- result_dict = {} # type : Dict[str, Dict[str, dict]]
365
+ result_dict : Dict [str , Dict [str , dict ]] = {}
368
366
for user_id , device_ids in query .items ():
369
367
# we use UserID.from_string to catch invalid user ids
370
368
if not self .is_mine (UserID .from_string (user_id )):
@@ -402,9 +400,9 @@ async def on_federation_query_client_keys(
402
400
self , query_body : Dict [str , Dict [str , Optional [List [str ]]]]
403
401
) -> JsonDict :
404
402
"""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 (
406
404
"device_keys" , {}
407
- ) # type: Dict[str, Optional[List[str]]]
405
+ )
408
406
res = await self .query_local_devices (device_keys_query )
409
407
ret = {"device_keys" : res }
410
408
@@ -421,8 +419,8 @@ async def on_federation_query_client_keys(
421
419
async def claim_one_time_keys (
422
420
self , query : Dict [str , Dict [str , Dict [str , str ]]], timeout : int
423
421
) -> 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 ]]] = {}
426
424
427
425
for user_id , one_time_keys in query .get ("one_time_keys" , {}).items ():
428
426
# we use UserID.from_string to catch invalid user ids
@@ -439,8 +437,8 @@ async def claim_one_time_keys(
439
437
results = await self .store .claim_e2e_one_time_keys (local_query )
440
438
441
439
# 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 ] = {}
444
442
for user_id , device_keys in results .items ():
445
443
for device_id , keys in device_keys .items ():
446
444
for key_id , json_str in keys .items ():
@@ -768,8 +766,8 @@ async def _process_self_signatures(
768
766
Raises:
769
767
SynapseError: if the input is malformed
770
768
"""
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 ]] = {}
773
771
if not signatures :
774
772
return signature_list , failures
775
773
@@ -930,8 +928,8 @@ async def _process_other_signatures(
930
928
Raises:
931
929
SynapseError: if the input is malformed
932
930
"""
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 ]] = {}
935
933
if not signatures :
936
934
return signature_list , failures
937
935
@@ -1300,7 +1298,7 @@ def __init__(self, hs: "HomeServer", e2e_keys_handler: E2eKeysHandler):
1300
1298
self ._remote_edu_linearizer = Linearizer (name = "remote_signing_key" )
1301
1299
1302
1300
# 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 ]]] = {}
1304
1302
1305
1303
async def incoming_signing_key_update (
1306
1304
self , origin : str , edu_content : JsonDict
@@ -1349,7 +1347,7 @@ async def _handle_signing_key_updates(self, user_id: str) -> None:
1349
1347
# This can happen since we batch updates
1350
1348
return
1351
1349
1352
- device_ids = [] # type: List[str ]
1350
+ device_ids : List [ str ] = [ ]
1353
1351
1354
1352
logger .info ("pending updates: %r" , pending_updates )
1355
1353
0 commit comments