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

Commit 8019ed3

Browse files
committed
Fix all the type issues
1 parent 0ac77b3 commit 8019ed3

File tree

17 files changed

+26
-24
lines changed

17 files changed

+26
-24
lines changed

synapse/appservice/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def __init__(
475475
self.as_api = as_api
476476
self.service = service
477477
self.callback = callback
478-
self.backoff_counter = 0
478+
self.backoff_counter = 0.0
479479

480480
def recover(self) -> None:
481481
def _retry() -> None:

synapse/handlers/room_batch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async def persist_historical_events(
285285
app_service_requester: Requester,
286286
also_allow_user: Optional[str],
287287
beeper_new_messages: bool,
288-
beeper_initial_prev_event_ids: List[str] = None,
288+
beeper_initial_prev_event_ids: Optional[List[str]] = None,
289289
) -> List[str]:
290290
"""Create and persists all events provided sequentially. Handles the
291291
complexity of creating events in chronological order so they can
@@ -426,13 +426,13 @@ async def handle_batch_of_events(
426426
self,
427427
events_to_create: List[JsonDict],
428428
room_id: str,
429-
batch_id_to_connect_to: str,
429+
batch_id_to_connect_to: Optional[str],
430430
inherited_depth: int,
431431
initial_state_event_ids: List[str],
432432
app_service_requester: Requester,
433433
also_allow_user: Optional[str],
434434
beeper_new_messages: bool,
435-
beeper_initial_prev_event_ids: List[str] = None,
435+
beeper_initial_prev_event_ids: Optional[List[str]] = None,
436436
) -> Tuple[List[str], str]:
437437
"""
438438
Handles creating and persisting all of the historical events as well as

synapse/http/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ def get_request_user_agent(request: IRequest, default: str = "") -> str:
101101

102102

103103
def get_request_beeper_bridge(request: IRequest) -> str:
104-
h = request.getHeader(b"X-Beeper-Bridge") # type: ignore
104+
h = request.getHeader(b"X-Beeper-Bridge")
105105
return h.decode("ascii", "replace") if h else ""

synapse/push/bulk_push_rule_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _should_count_as_unread(
6161
return isinstance(body, str) and bool(body)
6262
# Beeper: We want reactions to only count as unread if they're reactions to the current user in rooms that
6363
# have fewer than 20 users.
64-
elif event.type == "m.reaction":
64+
elif event.type == "m.reaction" and related_event:
6565
return (
6666
related_event.sender == current_user and non_bot_room_members_count < 20
6767
)

synapse/push/push_rule_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(
136136

137137
self._related_event = related_event
138138
self._related_event_value_cache = (
139-
_flatten_dict(related_event) if related_event else None
139+
_flatten_dict(related_event) if related_event else {}
140140
)
141141

142142
# Maps cache keys to final values.

synapse/rest/admin/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
9494
name = parse_string(request, "name")
9595
guests = parse_boolean(request, "guests", default=True)
9696
deactivated = parse_boolean(request, "deactivated", default=False)
97-
appservice = parse_string(request, "appservice", default=False)
97+
appservice = parse_string(request, "appservice")
9898

9999
order_by = parse_string(
100100
request,

synapse/rest/client/room_batch.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import logging
1616
import re
1717
from http import HTTPStatus
18-
from typing import TYPE_CHECKING, Awaitable, Tuple
18+
from typing import TYPE_CHECKING, Awaitable, Optional, Tuple
1919

2020
from twisted.web.server import Request
2121

@@ -107,8 +107,8 @@ async def on_POST(
107107
if self.enable_also_allow_user
108108
else None
109109
)
110-
beeper_new_messages = parse_boolean_from_args(
111-
request.args, "com.beeper.new_messages"
110+
beeper_new_messages = (
111+
parse_boolean_from_args(request.args, "com.beeper.new_messages") or False
112112
)
113113

114114
if prev_event_ids_from_query is None:
@@ -228,6 +228,8 @@ async def on_POST(
228228
EventContentFields.MSC2716_NEXT_BATCH_ID
229229
]
230230

231+
next_batch_id: Optional[str]
232+
231233
# Create and persist all of the historical events as well as insertion
232234
# and batch meta events to make the batch navigable in the DAG.
233235
event_ids, next_batch_id = await self.room_batch_handler.handle_batch_of_events(

synapse/storage/databases/main/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ async def get_users_paginate(
228228
deactivated: bool = False,
229229
order_by: str = UserSortOrder.USER_ID.value,
230230
direction: str = "f",
231-
appservice: bool = False,
231+
appservice: Optional[str] = None,
232232
) -> Tuple[List[JsonDict], int]:
233233
"""Function to retrieve a paginated list of users from
234234
users list. This will return a json list of users and the

synapse/storage/databases/main/roommember.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ async def get_number_joined_users_in_room(self, room_id: str) -> int:
407407
async def get_number_joined_non_bot_users_in_room(self, room_id: str) -> int:
408408
def _get_number_joined_non_bot_users_in_room_txn(
409409
txn: LoggingTransaction,
410-
) -> Dict[str, MemberSummary]:
410+
) -> int:
411411
sql = """
412412
SELECT COUNT(*)
413413
FROM current_state_events

tests/replication/slave/storage/test_receipts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
2929
STORE_TYPE = SlavedReceiptsStore
3030

3131
def prepare(self, reactor, clock, homeserver):
32-
self.clock._reactor.advance(1)
32+
self.clock._reactor.advance(1) # type: ignore
3333

3434
super().prepare(reactor, clock, homeserver)
3535
self.room_creator = homeserver.get_room_creation_handler()

0 commit comments

Comments
 (0)