-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reduce the number of "untyped defs" #12716
Changes from 8 commits
7cf850e
965ca4c
8e11e43
f16a82e
aac36ff
77d29f7
192ecf9
6979a84
d464f66
a225fda
cb1f07f
ed24f87
a5133c2
ebc5686
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ | |
|
||
@attr.s(slots=True, frozen=True) | ||
class WellKnownLookupResult: | ||
delegated_server = attr.ib() | ||
delegated_server: Optional[bytes] = attr.ib() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll chuck this in before merging. |
||
|
||
|
||
class WellKnownResolver: | ||
|
@@ -336,4 +336,4 @@ def _parse_cache_control(headers: Headers) -> Dict[bytes, Optional[bytes]]: | |
class _FetchWellKnownFailure(Exception): | ||
# True if we didn't get a non-5xx HTTP response, i.e. this may or may not be | ||
# a temporary failure. | ||
temporary = attr.ib() | ||
temporary: bool = attr.ib() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
Collection, | ||
Deque, | ||
Dict, | ||
Generator, | ||
Generic, | ||
Iterable, | ||
List, | ||
|
@@ -207,7 +208,7 @@ async def add_to_queue( | |
|
||
return res | ||
|
||
def _handle_queue(self, room_id): | ||
def _handle_queue(self, room_id: str) -> None: | ||
"""Attempts to handle the queue for a room if not already being handled. | ||
|
||
The queue's callback will be invoked with for each item in the queue, | ||
|
@@ -227,7 +228,7 @@ def _handle_queue(self, room_id): | |
|
||
self._currently_persisting_rooms.add(room_id) | ||
|
||
async def handle_queue_loop(): | ||
async def handle_queue_loop() -> None: | ||
try: | ||
queue = self._get_drainining_queue(room_id) | ||
for item in queue: | ||
|
@@ -250,15 +251,17 @@ async def handle_queue_loop(): | |
with PreserveLoggingContext(): | ||
item.deferred.callback(ret) | ||
finally: | ||
queue = self._event_persist_queues.pop(room_id, None) | ||
if queue: | ||
self._event_persist_queues[room_id] = queue | ||
remaining_queue = self._event_persist_queues.pop(room_id, None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't sure of the best name here. Mypy doesn't like it because it has a different type to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably fine, other options: |
||
if remaining_queue: | ||
self._event_persist_queues[room_id] = remaining_queue | ||
self._currently_persisting_rooms.discard(room_id) | ||
|
||
# set handle_queue_loop off in the background | ||
run_as_background_process("persist_events", handle_queue_loop) | ||
|
||
def _get_drainining_queue(self, room_id): | ||
def _get_drainining_queue( | ||
self, room_id: str | ||
) -> Generator[_EventPersistQueueItem, None, None]: | ||
queue = self._event_persist_queues.setdefault(room_id, deque()) | ||
|
||
try: | ||
|
@@ -317,7 +320,9 @@ async def persist_events( | |
for event, ctx in events_and_contexts: | ||
partitioned.setdefault(event.room_id, []).append((event, ctx)) | ||
|
||
async def enqueue(item): | ||
async def enqueue( | ||
item: Tuple[str, List[Tuple[EventBase, EventContext]]] | ||
) -> Dict[str, str]: | ||
room_id, evs_ctxs = item | ||
return await self._event_persist_queue.add_to_queue( | ||
room_id, evs_ctxs, backfilled=backfilled | ||
|
@@ -1102,7 +1107,7 @@ async def _is_server_still_joined( | |
|
||
return False | ||
|
||
async def _handle_potentially_left_users(self, user_ids: Set[str]): | ||
async def _handle_potentially_left_users(self, user_ids: Set[str]) -> None: | ||
"""Given a set of remote users check if the server still shares a room with | ||
them. If not then mark those users' device cache as stale. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to return
IOpenSSLClientConnectionCreator
, but as far as I can seeInsecureInterceptableContextFactory
doesn't implement that interface. I chose to ignore this because this is meant to be for testing only.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I ran into this too, there's a bit of funkiness in some of these interfaces that they don't all seem to be accurate.