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

Commit

Permalink
Bump black from 22.12.0 to 23.1.0 (#15103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Feb 22, 2023
1 parent 4ed08ff commit 9bb2eac
Show file tree
Hide file tree
Showing 117 changed files with 108 additions and 218 deletions.
1 change: 1 addition & 0 deletions changelog.d/15103.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump black from 22.12.0 to 23.1.0.
42 changes: 28 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion stubs/sortedcontainers/sortedlist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ _Repr = Callable[[], str]
def recursive_repr(fillvalue: str = ...) -> Callable[[_Repr], _Repr]: ...

class SortedList(MutableSequence[_T]):

DEFAULT_LOAD_FACTOR: int = ...
def __init__(
self,
Expand Down
2 changes: 0 additions & 2 deletions synapse/_scripts/register_new_matrix_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def request_registration(
_print: Callable[[str], None] = print,
exit: Callable[[int], None] = sys.exit,
) -> None:

url = "%s/_synapse/admin/v1/register" % (server_location.rstrip("/"),)

# Get the nonce
Expand Down Expand Up @@ -154,7 +153,6 @@ def register_new_user(


def main() -> None:

logging.captureWarnings(True)

parser = argparse.ArgumentParser(
Expand Down
1 change: 0 additions & 1 deletion synapse/_scripts/synapse_port_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,6 @@ def render(self, force: bool = False) -> None:
if self.finished:
status = "Time spent: %s (Done!)" % (duration_str,)
else:

if self.total_processed > 0:
left = float(self.total_remaining) / self.total_processed

Expand Down
1 change: 0 additions & 1 deletion synapse/_scripts/synctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def stop(pidfile: str, app: str) -> Optional[int]:


def main() -> None:

parser = argparse.ArgumentParser()

parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def handle_startup_exception(e: Exception) -> NoReturn:
def redirect_stdio_to_logs() -> None:
streams = [("stdout", LogLevel.info), ("stderr", LogLevel.error)]

for (stream, level) in streams:
for stream, level in streams:
oldStream = getattr(sys, stream)
loggingFile = LoggingFile(
logger=twisted.logger.Logger(namespace=stream),
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/complement_fork_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def handle_signal(signum: int, frame: Optional[FrameType]) -> None:
# memory space and don't need to repeat the work of loading the code!
# Instead of using fork() directly, we use the multiprocessing library,
# which uses fork() on Unix platforms.
for (func, worker_args) in zip(worker_functions, args_by_worker):
for func, worker_args in zip(worker_functions, args_by_worker):
process = multiprocessing.Process(
target=_worker_entrypoint, args=(func, proxy_reactor, worker_args)
)
Expand Down
1 change: 0 additions & 1 deletion synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class GenericWorkerServer(HomeServer):
DATASTORE_CLASS = GenericWorkerSlavedStore # type: ignore

def _listen_http(self, listener_config: ListenerConfig) -> None:

assert listener_config.http_options is not None

# We always include a health resource.
Expand Down
1 change: 0 additions & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ def setup(config_options: List[str]) -> SynapseHomeServer:
and not config.registration.registrations_require_3pid
and not config.registration.registration_requires_token
):

raise ConfigError(
"You have enabled open registration without any verification. This is a known vector for "
"spam and abuse. If you would like to allow public registration, please consider adding email, "
Expand Down
1 change: 0 additions & 1 deletion synapse/config/consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class ConsentConfig(Config):

section = "consent"

def __init__(self, *args: Any):
Expand Down
1 change: 0 additions & 1 deletion synapse/config/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def read_arguments(self, args: argparse.Namespace) -> None:
logger.warning(NON_SQLITE_DATABASE_PATH_WARNING)

def set_databasepath(self, database_path: str) -> None:

if database_path != ":memory:":
database_path = self.abspath(database_path)

Expand Down
1 change: 0 additions & 1 deletion synapse/config/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@


class HomeServerConfig(RootConfig):

config_classes = [
ModulesConfig,
ServerConfig,
Expand Down
1 change: 0 additions & 1 deletion synapse/config/ratelimiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class RatelimitConfig(Config):
section = "ratelimiting"

def read_config(self, config: JsonDict, **kwargs: Any) -> None:

# Load the new-style messages config if it exists. Otherwise fall back
# to the old method.
if "rc_message" in config:
Expand Down
1 change: 0 additions & 1 deletion synapse/config/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class ContentRepositoryConfig(Config):
section = "media"

def read_config(self, config: JsonDict, **kwargs: Any) -> None:

# Only enable the media repo if either the media repo is enabled or the
# current worker app is the media repo.
if (
Expand Down
1 change: 0 additions & 1 deletion synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ def generate_config_section(
listeners: Optional[List[dict]],
**kwargs: Any,
) -> str:

_, bind_port = parse_and_validate_server_name(server_name)
if bind_port is not None:
unsecure_port = bind_port - 400
Expand Down
1 change: 0 additions & 1 deletion synapse/config/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class TlsConfig(Config):
section = "tls"

def read_config(self, config: JsonDict, **kwargs: Any) -> None:

self.tls_certificate_file = self.abspath(config.get("tls_certificate_path"))
self.tls_private_key_file = self.abspath(config.get("tls_private_key_path"))

Expand Down
2 changes: 1 addition & 1 deletion synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ async def _inner_fetch_key_requests(
# We now convert the returned list of results into a map from server
# name to key ID to FetchKeyResult, to return.
to_return: Dict[str, Dict[str, FetchKeyResult]] = {}
for (request, results) in zip(deduped_requests, results_per_request):
for request, results in zip(deduped_requests, results_per_request):
to_return_by_server = to_return.setdefault(request.server_name, {})
for key_id, key_result in results.items():
existing = to_return_by_server.get(key_id)
Expand Down
2 changes: 0 additions & 2 deletions synapse/events/third_party_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def async_wrapper(f: Optional[Callable]) -> Optional[Callable[..., Awaitable]]:
# correctly, we need to await its result. Therefore it doesn't make a lot of
# sense to make it go through the run() wrapper.
if f.__name__ == "check_event_allowed":

# We need to wrap check_event_allowed because its old form would return either
# a boolean or a dict, but now we want to return the dict separately from the
# boolean.
Expand All @@ -100,7 +99,6 @@ async def wrap_check_event_allowed(
return wrap_check_event_allowed

if f.__name__ == "on_create_room":

# We need to wrap on_create_room because its old form would return a boolean
# if the room creation is denied, but now we just want it to raise an
# exception.
Expand Down
4 changes: 2 additions & 2 deletions synapse/federation/send_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def get_replication_rows(
# stream position.
keyed_edus = {v: k for k, v in self.keyed_edu_changed.items()[i:j]}

for ((destination, edu_key), pos) in keyed_edus.items():
for (destination, edu_key), pos in keyed_edus.items():
rows.append(
(
pos,
Expand All @@ -329,7 +329,7 @@ async def get_replication_rows(
j = self.edus.bisect_right(to_token) + 1
edus = self.edus.items()[i:j]

for (pos, edu) in edus:
for pos, edu in edus:
rows.append((pos, EduRow(edu)))

# Sort rows based on pos
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ async def query_3pe(
)

ret = []
for (success, result) in results:
for success, result in results:
if success:
ret.extend(result)

Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ async def refresh_token(
now_ms = self._clock.time_msec()

if existing_token.expiry_ts is not None and existing_token.expiry_ts < now_ms:

raise SynapseError(
HTTPStatus.FORBIDDEN,
"The supplied refresh token has expired",
Expand Down Expand Up @@ -2259,7 +2258,6 @@ async def check_3pid_auth(
async def on_logged_out(
self, user_id: str, device_id: Optional[str], access_token: str
) -> None:

# call all of the on_logged_out callbacks
for callback in self.on_logged_out_callbacks:
try:
Expand Down
8 changes: 5 additions & 3 deletions synapse/handlers/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,11 @@ async def edit_published_room_list(
raise SynapseError(403, "Not allowed to publish room")

# Check if publishing is blocked by a third party module
allowed_by_third_party_rules = await (
self.third_party_event_rules.check_visibility_can_be_modified(
room_id, visibility
allowed_by_third_party_rules = (
await (
self.third_party_event_rules.check_visibility_can_be_modified(
room_id, visibility
)
)
)
if not allowed_by_third_party_rules:
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ async def upload_room_keys(

# XXX: perhaps we should use a finer grained lock here?
async with self._upload_linearizer.queue(user_id):

# Check that the version we're trying to upload is the current version
try:
version_info = await self.store.get_e2e_room_keys_version_info(user_id)
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ async def check_restricted_join_rules(
# in any of them.
allowed_rooms = await self.get_rooms_that_allow_join(state_ids)
if not await self.is_user_in_rooms(allowed_rooms, user_id):

# If this is a remote request, the user might be in an allowed room
# that we do not know about.
if get_domain_from_id(user_id) != self._server_name:
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ async def _snapshot_all_rooms(
as_client_event: bool = True,
include_archived: bool = False,
) -> JsonDict:

memberships = [Membership.INVITE, Membership.JOIN]
if include_archived:
memberships.append(Membership.LEAVE)
Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ async def _on_shutdown(self) -> None:
)

if self.unpersisted_users_changes:

await self.store.update_presence(
[
self.user_to_current_state[user_id]
Expand Down Expand Up @@ -823,7 +822,6 @@ async def _update_states(
now = self.clock.time_msec()

with Measure(self.clock, "presence_update_states"):

# NOTE: We purposefully don't await between now and when we've
# calculated what we want to do with the new states, to avoid races.

Expand Down
8 changes: 5 additions & 3 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,11 @@ async def create_room(
)

# Check whether this visibility value is blocked by a third party module
allowed_by_third_party_rules = await (
self.third_party_event_rules.check_visibility_can_be_modified(
room_id, visibility
allowed_by_third_party_rules = (
await (
self.third_party_event_rules.check_visibility_can_be_modified(
room_id, visibility
)
)
)
if not allowed_by_third_party_rules:
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/room_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ async def persist_historical_events(
# correct stream_ordering as they are backfilled (which decrements).
# Events are sorted by (topological_ordering, stream_ordering)
# where topological_ordering is just depth.
for (event, context) in reversed(events_to_persist):
for event, context in reversed(events_to_persist):
# This call can't raise `PartialStateConflictError` since we forbid
# use of the historical batch API during partial state
await self.event_creation_handler.handle_new_client_event(
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ async def unread_notifs_for_room_id(
return RoomNotifCounts.empty()

with Measure(self.clock, "unread_notifs_for_room_id"):

return await self.store.get_unread_event_push_actions_by_room_for_user(
room_id,
sync_config.user.to_string(),
Expand Down
1 change: 1 addition & 0 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ def whitelisted_homeserver(destination: str) -> bool:

# Start spans and scopes


# Could use kwargs but I want these to be explicit
def start_active_span(
operation_name: str,
Expand Down
1 change: 0 additions & 1 deletion synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class LaterGauge(Collector):
]

def collect(self) -> Iterable[Metric]:

g = GaugeMetricFamily(self.name, self.desc, labels=self.labels)

try:
Expand Down
1 change: 0 additions & 1 deletion synapse/metrics/_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def _maybe_gc() -> None:

class PyPyGCStats(Collector):
def collect(self) -> Iterable[Metric]:

# @stats is a pretty-printer object with __str__() returning a nice table,
# plus some fields that contain data from that table.
# unfortunately, fields are pretty-printed themselves (i. e. '4.5MB').
Expand Down
1 change: 0 additions & 1 deletion synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ async def _action_for_event_by_user(
context: EventContext,
event_id_to_event: Mapping[str, EventBase],
) -> None:

if (
not event.internal_metadata.is_notifiable()
or event.internal_metadata.is_historical()
Expand Down
1 change: 0 additions & 1 deletion synapse/replication/http/account_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ def __init__(self, hs: "HomeServer"):

@staticmethod
async def _serialize_payload(user_id: str, room_id: str, tag: str) -> JsonDict: # type: ignore[override]

return {}

async def _handle_request( # type: ignore[override]
Expand Down
1 change: 0 additions & 1 deletion synapse/replication/http/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def __init__(self, hs: "HomeServer"):
async def _serialize_payload( # type: ignore[override]
user_id: str, device_id: str, keys: JsonDict
) -> JsonDict:

return {
"user_id": user_id,
"device_id": device_id,
Expand Down
Loading

0 comments on commit 9bb2eac

Please sign in to comment.