Use inline type hints in various other places (in synapse/) (#10380)

This commit is contained in:
Jonathan de Jong 2021-07-15 12:02:43 +02:00 committed by GitHub
parent c7603af1d0
commit bf72d10dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 329 additions and 336 deletions

View file

@ -86,7 +86,7 @@ class FederationClient(FederationBase):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.pdu_destination_tried = {} # type: Dict[str, Dict[str, int]]
self.pdu_destination_tried: Dict[str, Dict[str, int]] = {}
self._clock.looping_call(self._clear_tried_cache, 60 * 1000)
self.state = hs.get_state_handler()
self.transport_layer = hs.get_federation_transport_client()
@ -94,13 +94,13 @@ class FederationClient(FederationBase):
self.hostname = hs.hostname
self.signing_key = hs.signing_key
self._get_pdu_cache = ExpiringCache(
self._get_pdu_cache: ExpiringCache[str, EventBase] = ExpiringCache(
cache_name="get_pdu_cache",
clock=self._clock,
max_len=1000,
expiry_ms=120 * 1000,
reset_expiry_on_get=False,
) # type: ExpiringCache[str, EventBase]
)
def _clear_tried_cache(self):
"""Clear pdu_destination_tried cache"""
@ -293,10 +293,10 @@ class FederationClient(FederationBase):
transaction_data,
)
pdu_list = [
pdu_list: List[EventBase] = [
event_from_pdu_json(p, room_version, outlier=outlier)
for p in transaction_data["pdus"]
] # type: List[EventBase]
]
if pdu_list and pdu_list[0]:
pdu = pdu_list[0]