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

Commit 9bb2eac

Browse files
Bump black from 22.12.0 to 23.1.0 (#15103)
1 parent 4ed08ff commit 9bb2eac

File tree

117 files changed

+108
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+108
-218
lines changed

changelog.d/15103.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump black from 22.12.0 to 23.1.0.

poetry.lock

+28-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stubs/sortedcontainers/sortedlist.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ _Repr = Callable[[], str]
2929
def recursive_repr(fillvalue: str = ...) -> Callable[[_Repr], _Repr]: ...
3030

3131
class SortedList(MutableSequence[_T]):
32-
3332
DEFAULT_LOAD_FACTOR: int = ...
3433
def __init__(
3534
self,

synapse/_scripts/register_new_matrix_user.py

-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def request_registration(
4747
_print: Callable[[str], None] = print,
4848
exit: Callable[[int], None] = sys.exit,
4949
) -> None:
50-
5150
url = "%s/_synapse/admin/v1/register" % (server_location.rstrip("/"),)
5251

5352
# Get the nonce
@@ -154,7 +153,6 @@ def register_new_user(
154153

155154

156155
def main() -> None:
157-
158156
logging.captureWarnings(True)
159157

160158
parser = argparse.ArgumentParser(

synapse/_scripts/synapse_port_db.py

-1
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,6 @@ def render(self, force: bool = False) -> None:
12051205
if self.finished:
12061206
status = "Time spent: %s (Done!)" % (duration_str,)
12071207
else:
1208-
12091208
if self.total_processed > 0:
12101209
left = float(self.total_remaining) / self.total_processed
12111210

synapse/_scripts/synctl.py

-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ def stop(pidfile: str, app: str) -> Optional[int]:
167167

168168

169169
def main() -> None:
170-
171170
parser = argparse.ArgumentParser()
172171

173172
parser.add_argument(

synapse/app/_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def handle_startup_exception(e: Exception) -> NoReturn:
213213
def redirect_stdio_to_logs() -> None:
214214
streams = [("stdout", LogLevel.info), ("stderr", LogLevel.error)]
215215

216-
for (stream, level) in streams:
216+
for stream, level in streams:
217217
oldStream = getattr(sys, stream)
218218
loggingFile = LoggingFile(
219219
logger=twisted.logger.Logger(namespace=stream),

synapse/app/complement_fork_starter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def handle_signal(signum: int, frame: Optional[FrameType]) -> None:
219219
# memory space and don't need to repeat the work of loading the code!
220220
# Instead of using fork() directly, we use the multiprocessing library,
221221
# which uses fork() on Unix platforms.
222-
for (func, worker_args) in zip(worker_functions, args_by_worker):
222+
for func, worker_args in zip(worker_functions, args_by_worker):
223223
process = multiprocessing.Process(
224224
target=_worker_entrypoint, args=(func, proxy_reactor, worker_args)
225225
)

synapse/app/generic_worker.py

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ class GenericWorkerServer(HomeServer):
157157
DATASTORE_CLASS = GenericWorkerSlavedStore # type: ignore
158158

159159
def _listen_http(self, listener_config: ListenerConfig) -> None:
160-
161160
assert listener_config.http_options is not None
162161

163162
# We always include a health resource.

synapse/app/homeserver.py

-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ def setup(config_options: List[str]) -> SynapseHomeServer:
321321
and not config.registration.registrations_require_3pid
322322
and not config.registration.registration_requires_token
323323
):
324-
325324
raise ConfigError(
326325
"You have enabled open registration without any verification. This is a known vector for "
327326
"spam and abuse. If you would like to allow public registration, please consider adding email, "

synapse/config/consent.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323

2424
class ConsentConfig(Config):
25-
2625
section = "consent"
2726

2827
def __init__(self, *args: Any):

synapse/config/database.py

-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ def read_arguments(self, args: argparse.Namespace) -> None:
154154
logger.warning(NON_SQLITE_DATABASE_PATH_WARNING)
155155

156156
def set_databasepath(self, database_path: str) -> None:
157-
158157
if database_path != ":memory:":
159158
database_path = self.abspath(database_path)
160159

synapse/config/homeserver.py

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757

5858
class HomeServerConfig(RootConfig):
59-
6059
config_classes = [
6160
ModulesConfig,
6261
ServerConfig,

synapse/config/ratelimiting.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class RatelimitConfig(Config):
4646
section = "ratelimiting"
4747

4848
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
49-
5049
# Load the new-style messages config if it exists. Otherwise fall back
5150
# to the old method.
5251
if "rc_message" in config:

synapse/config/repository.py

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class ContentRepositoryConfig(Config):
116116
section = "media"
117117

118118
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
119-
120119
# Only enable the media repo if either the media repo is enabled or the
121120
# current worker app is the media repo.
122121
if (

synapse/config/server.py

-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ def generate_config_section(
735735
listeners: Optional[List[dict]],
736736
**kwargs: Any,
737737
) -> str:
738-
739738
_, bind_port = parse_and_validate_server_name(server_name)
740739
if bind_port is not None:
741740
unsecure_port = bind_port - 400

synapse/config/tls.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class TlsConfig(Config):
3030
section = "tls"
3131

3232
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
33-
3433
self.tls_certificate_file = self.abspath(config.get("tls_certificate_path"))
3534
self.tls_private_key_file = self.abspath(config.get("tls_private_key_path"))
3635

synapse/crypto/keyring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ async def _inner_fetch_key_requests(
399399
# We now convert the returned list of results into a map from server
400400
# name to key ID to FetchKeyResult, to return.
401401
to_return: Dict[str, Dict[str, FetchKeyResult]] = {}
402-
for (request, results) in zip(deduped_requests, results_per_request):
402+
for request, results in zip(deduped_requests, results_per_request):
403403
to_return_by_server = to_return.setdefault(request.server_name, {})
404404
for key_id, key_result in results.items():
405405
existing = to_return_by_server.get(key_id)

synapse/events/third_party_rules.py

-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def async_wrapper(f: Optional[Callable]) -> Optional[Callable[..., Awaitable]]:
7878
# correctly, we need to await its result. Therefore it doesn't make a lot of
7979
# sense to make it go through the run() wrapper.
8080
if f.__name__ == "check_event_allowed":
81-
8281
# We need to wrap check_event_allowed because its old form would return either
8382
# a boolean or a dict, but now we want to return the dict separately from the
8483
# boolean.
@@ -100,7 +99,6 @@ async def wrap_check_event_allowed(
10099
return wrap_check_event_allowed
101100

102101
if f.__name__ == "on_create_room":
103-
104102
# We need to wrap on_create_room because its old form would return a boolean
105103
# if the room creation is denied, but now we just want it to raise an
106104
# exception.

synapse/federation/send_queue.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async def get_replication_rows(
314314
# stream position.
315315
keyed_edus = {v: k for k, v in self.keyed_edu_changed.items()[i:j]}
316316

317-
for ((destination, edu_key), pos) in keyed_edus.items():
317+
for (destination, edu_key), pos in keyed_edus.items():
318318
rows.append(
319319
(
320320
pos,
@@ -329,7 +329,7 @@ async def get_replication_rows(
329329
j = self.edus.bisect_right(to_token) + 1
330330
edus = self.edus.items()[i:j]
331331

332-
for (pos, edu) in edus:
332+
for pos, edu in edus:
333333
rows.append((pos, EduRow(edu)))
334334

335335
# Sort rows based on pos

synapse/handlers/appservice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ async def query_3pe(
737737
)
738738

739739
ret = []
740-
for (success, result) in results:
740+
for success, result in results:
741741
if success:
742742
ret.extend(result)
743743

synapse/handlers/auth.py

-2
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ async def refresh_token(
815815
now_ms = self._clock.time_msec()
816816

817817
if existing_token.expiry_ts is not None and existing_token.expiry_ts < now_ms:
818-
819818
raise SynapseError(
820819
HTTPStatus.FORBIDDEN,
821820
"The supplied refresh token has expired",
@@ -2259,7 +2258,6 @@ async def check_3pid_auth(
22592258
async def on_logged_out(
22602259
self, user_id: str, device_id: Optional[str], access_token: str
22612260
) -> None:
2262-
22632261
# call all of the on_logged_out callbacks
22642262
for callback in self.on_logged_out_callbacks:
22652263
try:

synapse/handlers/directory.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,11 @@ async def edit_published_room_list(
497497
raise SynapseError(403, "Not allowed to publish room")
498498

499499
# Check if publishing is blocked by a third party module
500-
allowed_by_third_party_rules = await (
501-
self.third_party_event_rules.check_visibility_can_be_modified(
502-
room_id, visibility
500+
allowed_by_third_party_rules = (
501+
await (
502+
self.third_party_event_rules.check_visibility_can_be_modified(
503+
room_id, visibility
504+
)
503505
)
504506
)
505507
if not allowed_by_third_party_rules:

synapse/handlers/e2e_room_keys.py

-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ async def upload_room_keys(
188188

189189
# XXX: perhaps we should use a finer grained lock here?
190190
async with self._upload_linearizer.queue(user_id):
191-
192191
# Check that the version we're trying to upload is the current version
193192
try:
194193
version_info = await self.store.get_e2e_room_keys_version_info(user_id)

synapse/handlers/event_auth.py

-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ async def check_restricted_join_rules(
236236
# in any of them.
237237
allowed_rooms = await self.get_rooms_that_allow_join(state_ids)
238238
if not await self.is_user_in_rooms(allowed_rooms, user_id):
239-
240239
# If this is a remote request, the user might be in an allowed room
241240
# that we do not know about.
242241
if get_domain_from_id(user_id) != self._server_name:

synapse/handlers/initial_sync.py

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ async def _snapshot_all_rooms(
124124
as_client_event: bool = True,
125125
include_archived: bool = False,
126126
) -> JsonDict:
127-
128127
memberships = [Membership.INVITE, Membership.JOIN]
129128
if include_archived:
130129
memberships.append(Membership.LEAVE)

synapse/handlers/presence.py

-2
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ async def _on_shutdown(self) -> None:
777777
)
778778

779779
if self.unpersisted_users_changes:
780-
781780
await self.store.update_presence(
782781
[
783782
self.user_to_current_state[user_id]
@@ -823,7 +822,6 @@ async def _update_states(
823822
now = self.clock.time_msec()
824823

825824
with Measure(self.clock, "presence_update_states"):
826-
827825
# NOTE: We purposefully don't await between now and when we've
828826
# calculated what we want to do with the new states, to avoid races.
829827

synapse/handlers/room.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,11 @@ async def create_room(
868868
)
869869

870870
# Check whether this visibility value is blocked by a third party module
871-
allowed_by_third_party_rules = await (
872-
self.third_party_event_rules.check_visibility_can_be_modified(
873-
room_id, visibility
871+
allowed_by_third_party_rules = (
872+
await (
873+
self.third_party_event_rules.check_visibility_can_be_modified(
874+
room_id, visibility
875+
)
874876
)
875877
)
876878
if not allowed_by_third_party_rules:

synapse/handlers/room_batch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async def persist_historical_events(
374374
# correct stream_ordering as they are backfilled (which decrements).
375375
# Events are sorted by (topological_ordering, stream_ordering)
376376
# where topological_ordering is just depth.
377-
for (event, context) in reversed(events_to_persist):
377+
for event, context in reversed(events_to_persist):
378378
# This call can't raise `PartialStateConflictError` since we forbid
379379
# use of the historical batch API during partial state
380380
await self.event_creation_handler.handle_new_client_event(

synapse/handlers/sync.py

-1
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,6 @@ async def unread_notifs_for_room_id(
12971297
return RoomNotifCounts.empty()
12981298

12991299
with Measure(self.clock, "unread_notifs_for_room_id"):
1300-
13011300
return await self.store.get_unread_event_push_actions_by_room_for_user(
13021301
room_id,
13031302
sync_config.user.to_string(),

synapse/logging/opentracing.py

+1
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def whitelisted_homeserver(destination: str) -> bool:
524524

525525
# Start spans and scopes
526526

527+
527528
# Could use kwargs but I want these to be explicit
528529
def start_active_span(
529530
operation_name: str,

synapse/metrics/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class LaterGauge(Collector):
8787
]
8888

8989
def collect(self) -> Iterable[Metric]:
90-
9190
g = GaugeMetricFamily(self.name, self.desc, labels=self.labels)
9291

9392
try:

synapse/metrics/_gc.py

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def _maybe_gc() -> None:
139139

140140
class PyPyGCStats(Collector):
141141
def collect(self) -> Iterable[Metric]:
142-
143142
# @stats is a pretty-printer object with __str__() returning a nice table,
144143
# plus some fields that contain data from that table.
145144
# unfortunately, fields are pretty-printed themselves (i. e. '4.5MB').

synapse/push/bulk_push_rule_evaluator.py

-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ async def _action_for_event_by_user(
330330
context: EventContext,
331331
event_id_to_event: Mapping[str, EventBase],
332332
) -> None:
333-
334333
if (
335334
not event.internal_metadata.is_notifiable()
336335
or event.internal_metadata.is_historical()

synapse/replication/http/account_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ def __init__(self, hs: "HomeServer"):
265265

266266
@staticmethod
267267
async def _serialize_payload(user_id: str, room_id: str, tag: str) -> JsonDict: # type: ignore[override]
268-
269268
return {}
270269

271270
async def _handle_request( # type: ignore[override]

synapse/replication/http/devices.py

-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def __init__(self, hs: "HomeServer"):
195195
async def _serialize_payload( # type: ignore[override]
196196
user_id: str, device_id: str, keys: JsonDict
197197
) -> JsonDict:
198-
199198
return {
200199
"user_id": user_id,
201200
"device_id": device_id,

0 commit comments

Comments
 (0)