mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 22:14:55 -04:00
Require type hints in the handlers module. (#10831)
Adds missing type hints to methods in the synapse.handlers module and requires all methods to have type hints there. This also removes the unused construct_auth_difference method from the FederationHandler.
This commit is contained in:
parent
437961744c
commit
b3590614da
35 changed files with 194 additions and 295 deletions
|
@ -46,6 +46,7 @@ from synapse.events import EventBase
|
|||
from synapse.events.builder import EventBuilder
|
||||
from synapse.events.snapshot import EventContext
|
||||
from synapse.events.validator import EventValidator
|
||||
from synapse.handlers.directory import DirectoryHandler
|
||||
from synapse.logging.context import make_deferred_yieldable, run_in_background
|
||||
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||
from synapse.replication.http.send_event import ReplicationSendEventRestServlet
|
||||
|
@ -298,7 +299,7 @@ class MessageHandler:
|
|||
for user_id, profile in users_with_profile.items()
|
||||
}
|
||||
|
||||
def maybe_schedule_expiry(self, event: EventBase):
|
||||
def maybe_schedule_expiry(self, event: EventBase) -> None:
|
||||
"""Schedule the expiry of an event if there's not already one scheduled,
|
||||
or if the one running is for an event that will expire after the provided
|
||||
timestamp.
|
||||
|
@ -318,7 +319,7 @@ class MessageHandler:
|
|||
# a task scheduled for a timestamp that's sooner than the provided one.
|
||||
self._schedule_expiry_for_event(event.event_id, expiry_ts)
|
||||
|
||||
async def _schedule_next_expiry(self):
|
||||
async def _schedule_next_expiry(self) -> None:
|
||||
"""Retrieve the ID and the expiry timestamp of the next event to be expired,
|
||||
and schedule an expiry task for it.
|
||||
|
||||
|
@ -331,7 +332,7 @@ class MessageHandler:
|
|||
event_id, expiry_ts = res
|
||||
self._schedule_expiry_for_event(event_id, expiry_ts)
|
||||
|
||||
def _schedule_expiry_for_event(self, event_id: str, expiry_ts: int):
|
||||
def _schedule_expiry_for_event(self, event_id: str, expiry_ts: int) -> None:
|
||||
"""Schedule an expiry task for the provided event if there's not already one
|
||||
scheduled at a timestamp that's sooner than the provided one.
|
||||
|
||||
|
@ -367,7 +368,7 @@ class MessageHandler:
|
|||
event_id,
|
||||
)
|
||||
|
||||
async def _expire_event(self, event_id: str):
|
||||
async def _expire_event(self, event_id: str) -> None:
|
||||
"""Retrieve and expire an event that needs to be expired from the database.
|
||||
|
||||
If the event doesn't exist in the database, log it and delete the expiry date
|
||||
|
@ -1229,7 +1230,10 @@ class EventCreationHandler:
|
|||
self._external_cache_joined_hosts_updates[state_entry.state_group] = None
|
||||
|
||||
async def _validate_canonical_alias(
|
||||
self, directory_handler, room_alias_str: str, expected_room_id: str
|
||||
self,
|
||||
directory_handler: DirectoryHandler,
|
||||
room_alias_str: str,
|
||||
expected_room_id: str,
|
||||
) -> None:
|
||||
"""
|
||||
Ensure that the given room alias points to the expected room ID.
|
||||
|
@ -1477,7 +1481,7 @@ class EventCreationHandler:
|
|||
# If there's an expiry timestamp on the event, schedule its expiry.
|
||||
self._message_handler.maybe_schedule_expiry(event)
|
||||
|
||||
def _notify():
|
||||
def _notify() -> None:
|
||||
try:
|
||||
self.notifier.on_new_room_event(
|
||||
event, event_pos, max_stream_token, extra_users=extra_users
|
||||
|
@ -1523,7 +1527,7 @@ class EventCreationHandler:
|
|||
except Exception:
|
||||
logger.exception("Error bumping presence active time")
|
||||
|
||||
async def _send_dummy_events_to_fill_extremities(self):
|
||||
async def _send_dummy_events_to_fill_extremities(self) -> None:
|
||||
"""Background task to send dummy events into rooms that have a large
|
||||
number of extremities
|
||||
"""
|
||||
|
@ -1600,7 +1604,7 @@ class EventCreationHandler:
|
|||
)
|
||||
return False
|
||||
|
||||
def _expire_rooms_to_exclude_from_dummy_event_insertion(self):
|
||||
def _expire_rooms_to_exclude_from_dummy_event_insertion(self) -> None:
|
||||
expire_before = self.clock.time_msec() - _DUMMY_EVENT_ROOM_EXCLUSION_EXPIRY
|
||||
to_expire = set()
|
||||
for room_id, time in self._rooms_to_exclude_from_dummy_event_insertion.items():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue