Skip to content

Commit 4a5c2f8

Browse files
committed
Fix lints
1 parent fc04be1 commit 4a5c2f8

24 files changed

Lines changed: 112 additions & 114 deletions

synapse/_scripts/synctl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ def main() -> None:
292292
for key in worker_config:
293293
if key == "worker_app": # But we allow worker_app
294294
continue
295-
assert not key.startswith("worker_"), (
296-
"Main process cannot use worker_* config"
297-
)
295+
assert not key.startswith(
296+
"worker_"
297+
), "Main process cannot use worker_* config"
298298
else:
299299
worker_pidfile = worker_config["worker_pid_file"]
300300
worker_cache_factor = worker_config.get("synctl_cache_factor")

synapse/handlers/federation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,9 @@ async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:
13121312
if state_key is not None:
13131313
# the event was not rejected (get_event raises a NotFoundError for rejected
13141314
# events) so the state at the event should include the event itself.
1315-
assert state_map.get((event.type, state_key)) == event.event_id, (
1316-
"State at event did not include event itself"
1317-
)
1315+
assert (
1316+
state_map.get((event.type, state_key)) == event.event_id
1317+
), "State at event did not include event itself"
13181318

13191319
# ... but we need the state *before* that event
13201320
if "replaces_state" in event.unsigned:

synapse/handlers/message.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ async def get_room_data(
143143
elif membership == Membership.LEAVE:
144144
key = (event_type, state_key)
145145
# If the membership is not JOIN, then the event ID should exist.
146-
assert membership_event_id is not None, (
147-
"check_user_in_room_or_world_readable returned invalid data"
148-
)
146+
assert (
147+
membership_event_id is not None
148+
), "check_user_in_room_or_world_readable returned invalid data"
149149
room_state = await self._state_storage_controller.get_state_for_events(
150150
[membership_event_id], StateFilter.from_types([key])
151151
)
@@ -242,9 +242,9 @@ async def get_state_events(
242242
room_state = await self.store.get_events(state_ids.values())
243243
elif membership == Membership.LEAVE:
244244
# If the membership is not JOIN, then the event ID should exist.
245-
assert membership_event_id is not None, (
246-
"check_user_in_room_or_world_readable returned invalid data"
247-
)
245+
assert (
246+
membership_event_id is not None
247+
), "check_user_in_room_or_world_readable returned invalid data"
248248
room_state_events = (
249249
await self._state_storage_controller.get_state_for_events(
250250
[membership_event_id], state_filter=state_filter
@@ -1267,14 +1267,12 @@ async def create_new_client_event(
12671267
# Allow an event to have empty list of prev_event_ids
12681268
# only if it has auth_event_ids.
12691269
or auth_event_ids
1270-
), (
1271-
"Attempting to create a non-m.room.create event with no prev_events or auth_event_ids"
1272-
)
1270+
), "Attempting to create a non-m.room.create event with no prev_events or auth_event_ids"
12731271
else:
12741272
# we now ought to have some prev_events (unless it's a create event).
1275-
assert builder.type == EventTypes.Create or prev_event_ids, (
1276-
"Attempting to create a non-m.room.create event with no prev_events"
1277-
)
1273+
assert (
1274+
builder.type == EventTypes.Create or prev_event_ids
1275+
), "Attempting to create a non-m.room.create event with no prev_events"
12781276

12791277
if for_batch:
12801278
assert prev_event_ids is not None

synapse/handlers/sso.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,9 @@ async def revoke_sessions_for_provider_session_id(
11921192
"""
11931193

11941194
# It is expected that this is the main process.
1195-
assert isinstance(self._device_handler, DeviceHandler), (
1196-
"revoking SSO sessions can only be called on the main process"
1197-
)
1195+
assert isinstance(
1196+
self._device_handler, DeviceHandler
1197+
), "revoking SSO sessions can only be called on the main process"
11981198

11991199
# Invalidate any running user-mapping sessions
12001200
to_delete = []

synapse/http/matrixfederationclient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ def __init__(
426426
)
427427
else:
428428
proxy_authorization_secret = hs.config.worker.worker_replication_secret
429-
assert proxy_authorization_secret is not None, (
430-
"`worker_replication_secret` must be set when using `outbound_federation_restricted_to` (used to authenticate requests across workers)"
431-
)
429+
assert (
430+
proxy_authorization_secret is not None
431+
), "`worker_replication_secret` must be set when using `outbound_federation_restricted_to` (used to authenticate requests across workers)"
432432
federation_proxy_credentials = BearerProxyCredentials(
433433
proxy_authorization_secret.encode("ascii")
434434
)

synapse/http/proxyagent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def __init__(
173173
self._federation_proxy_endpoint: Optional[IStreamClientEndpoint] = None
174174
self._federation_proxy_credentials: Optional[ProxyCredentials] = None
175175
if federation_proxy_locations:
176-
assert federation_proxy_credentials is not None, (
177-
"`federation_proxy_credentials` are required when using `federation_proxy_locations`"
178-
)
176+
assert (
177+
federation_proxy_credentials is not None
178+
), "`federation_proxy_credentials` are required when using `federation_proxy_locations`"
179179

180180
endpoints: List[IStreamClientEndpoint] = []
181181
for federation_proxy_location in federation_proxy_locations:
@@ -302,9 +302,9 @@ def request(
302302
parsed_uri.scheme == b"matrix-federation"
303303
and self._federation_proxy_endpoint
304304
):
305-
assert self._federation_proxy_credentials is not None, (
306-
"`federation_proxy_credentials` are required when using `federation_proxy_locations`"
307-
)
305+
assert (
306+
self._federation_proxy_credentials is not None
307+
), "`federation_proxy_credentials` are required when using `federation_proxy_locations`"
308308

309309
# Set a Proxy-Authorization header
310310
if headers is None:

synapse/http/servlet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ def parse_enum(
582582
is not one of those allowed values.
583583
"""
584584
# Assert the enum values are strings.
585-
assert all(isinstance(e.value, str) for e in E), (
586-
"parse_enum only works with string values"
587-
)
585+
assert all(
586+
isinstance(e.value, str) for e in E
587+
), "parse_enum only works with string values"
588588
str_value = parse_string(
589589
request,
590590
name,

synapse/module_api/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ def invalidate_access_token(
894894
Raises:
895895
synapse.api.errors.AuthError: the access token is invalid
896896
"""
897-
assert isinstance(self._device_handler, DeviceHandler), (
898-
"invalidate_access_token can only be called on the main process"
899-
)
897+
assert isinstance(
898+
self._device_handler, DeviceHandler
899+
), "invalidate_access_token can only be called on the main process"
900900

901901
# see if the access token corresponds to a device
902902
user_info = yield defer.ensureDeferred(

synapse/replication/http/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def __init__(self, hs: "HomeServer"):
131131

132132
# We reserve `instance_name` as a parameter to sending requests, so we
133133
# assert here that sub classes don't try and use the name.
134-
assert "instance_name" not in self.PATH_ARGS, (
135-
"`instance_name` is a reserved parameter name"
136-
)
134+
assert (
135+
"instance_name" not in self.PATH_ARGS
136+
), "`instance_name` is a reserved parameter name"
137137
assert (
138138
"instance_name"
139139
not in signature(self.__class__._serialize_payload).parameters

synapse/replication/tcp/streams/events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ async def _update_function(
200200

201201
# we rely on get_all_new_forward_event_rows strictly honouring the limit, so
202202
# that we know it is safe to just take upper_limit = event_rows[-1][0].
203-
assert len(event_rows) <= target_row_count, (
204-
"get_all_new_forward_event_rows did not honour row limit"
205-
)
203+
assert (
204+
len(event_rows) <= target_row_count
205+
), "get_all_new_forward_event_rows did not honour row limit"
206206

207207
# if we hit the limit on event_updates, there's no point in going beyond the
208208
# last stream_id in the batch for the other sources.

0 commit comments

Comments
 (0)