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

Bump black from 22.12.0 to 23.1.0 #15103

Merged
merged 5 commits into from
Feb 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run black.
clokep committed Feb 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5d439fa829b7f171b77b0cedbd4fdf80b137e25d
1 change: 0 additions & 1 deletion stubs/sortedcontainers/sortedlist.pyi
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 0 additions & 2 deletions synapse/_scripts/register_new_matrix_user.py
Original file line number Diff line number Diff line change
@@ -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
@@ -154,7 +153,6 @@ def register_new_user(


def main() -> None:

logging.captureWarnings(True)

parser = argparse.ArgumentParser(
1 change: 0 additions & 1 deletion synapse/_scripts/synapse_port_db.py
Original file line number Diff line number Diff line change
@@ -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

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


def main() -> None:

parser = argparse.ArgumentParser()

parser.add_argument(
2 changes: 1 addition & 1 deletion synapse/app/_base.py
Original file line number Diff line number Diff line change
@@ -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),
2 changes: 1 addition & 1 deletion synapse/app/complement_fork_starter.py
Original file line number Diff line number Diff line change
@@ -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)
)
1 change: 0 additions & 1 deletion synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
@@ -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, "
1 change: 0 additions & 1 deletion synapse/config/consent.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@


class ConsentConfig(Config):

section = "consent"

def __init__(self, *args: Any):
1 change: 0 additions & 1 deletion synapse/config/database.py
Original file line number Diff line number Diff line change
@@ -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)

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


class HomeServerConfig(RootConfig):

config_classes = [
ModulesConfig,
ServerConfig,
1 change: 0 additions & 1 deletion synapse/config/ratelimiting.py
Original file line number Diff line number Diff line change
@@ -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:
1 change: 0 additions & 1 deletion synapse/config/repository.py
Original file line number Diff line number Diff line change
@@ -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 (
1 change: 0 additions & 1 deletion synapse/config/server.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion synapse/config/tls.py
Original file line number Diff line number Diff line change
@@ -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"))

2 changes: 1 addition & 1 deletion synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 0 additions & 2 deletions synapse/events/third_party_rules.py
Original file line number Diff line number Diff line change
@@ -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.
@@ -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.
4 changes: 2 additions & 2 deletions synapse/federation/send_queue.py
Original file line number Diff line number Diff line change
@@ -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,
@@ -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
2 changes: 1 addition & 1 deletion synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
@@ -737,7 +737,7 @@ async def query_3pe(
)

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

2 changes: 0 additions & 2 deletions synapse/handlers/auth.py
Original file line number Diff line number Diff line change
@@ -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",
@@ -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:
8 changes: 5 additions & 3 deletions synapse/handlers/directory.py
Original file line number Diff line number Diff line change
@@ -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:
1 change: 0 additions & 1 deletion synapse/handlers/e2e_room_keys.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
@@ -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:
1 change: 0 additions & 1 deletion synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 0 additions & 2 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
@@ -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]
@@ -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.

8 changes: 5 additions & 3 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion synapse/handlers/room_batch.py
Original file line number Diff line number Diff line change
@@ -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(
1 change: 0 additions & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
@@ -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(),
1 change: 1 addition & 0 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
@@ -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,
1 change: 0 additions & 1 deletion synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -87,7 +87,6 @@ class LaterGauge(Collector):
]

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

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

try:
1 change: 0 additions & 1 deletion synapse/metrics/_gc.py
Original file line number Diff line number Diff line change
@@ -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').
1 change: 0 additions & 1 deletion synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 0 additions & 1 deletion synapse/replication/http/account_data.py
Original file line number Diff line number Diff line change
@@ -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]
1 change: 0 additions & 1 deletion synapse/replication/http/devices.py
Original file line number Diff line number Diff line change
@@ -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,
1 change: 0 additions & 1 deletion synapse/replication/tcp/redis.py
Original file line number Diff line number Diff line change
@@ -328,7 +328,6 @@ def __init__(
outbound_redis_connection: txredisapi.ConnectionHandler,
channel_names: List[str],
):

super().__init__(
hs,
uuid="subscriber",
1 change: 0 additions & 1 deletion synapse/replication/tcp/streams/events.py
Original file line number Diff line number Diff line change
@@ -139,7 +139,6 @@ async def _update_function(
current_token: Token,
target_row_count: int,
) -> StreamUpdateResult:

# the events stream merges together three separate sources:
# * new events
# * current_state changes
4 changes: 0 additions & 4 deletions synapse/rest/admin/rooms.py
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ def __init__(self, hs: "HomeServer"):
async def on_DELETE(
self, request: SynapseRequest, room_id: str
) -> Tuple[int, JsonDict]:

requester = await self._auth.get_user_by_req(request)
await assert_user_is_admin(self._auth, requester)

@@ -144,7 +143,6 @@ def __init__(self, hs: "HomeServer"):
async def on_GET(
self, request: SynapseRequest, room_id: str
) -> Tuple[int, JsonDict]:

await assert_requester_is_admin(self._auth, request)

if not RoomID.is_valid(room_id):
@@ -181,7 +179,6 @@ def __init__(self, hs: "HomeServer"):
async def on_GET(
self, request: SynapseRequest, delete_id: str
) -> Tuple[int, JsonDict]:

await assert_requester_is_admin(self._auth, request)

delete_status = self._pagination_handler.get_delete_status(delete_id)
@@ -438,7 +435,6 @@ async def on_GET(


class JoinRoomAliasServlet(ResolveRoomIdMixin, RestServlet):

PATTERNS = admin_patterns("/join/(?P<room_identifier>[^/]*)$")

def __init__(self, hs: "HomeServer"):
8 changes: 6 additions & 2 deletions synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
@@ -683,8 +683,12 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
await assert_requester_is_admin(self.auth, request)

if self.account_activity_handler.on_legacy_admin_request_callback:
expiration_ts = await (
self.account_activity_handler.on_legacy_admin_request_callback(request)
expiration_ts = (
await (
self.account_activity_handler.on_legacy_admin_request_callback(
request
)
)
)
else:
body = parse_json_object_from_request(request)
Loading