diff --git a/synapse/config/repository.py b/synapse/config/repository.py index feff90cfb..95b24ed97 100644 --- a/synapse/config/repository.py +++ b/synapse/config/repository.py @@ -94,8 +94,12 @@ class ContentRepositoryConfig(Config): self.max_spider_size = self.parse_size(config.get("max_spider_size", "10M")) if self.enable_media_repo: - self.media_store_path = self.ensure_directory(config.get("media_store_path", "media_store")) - self.uploads_path = self.ensure_directory(config.get("uploads_path", "uploads")) + self.media_store_path = self.ensure_directory( + config.get("media_store_path", "media_store") + ) + self.uploads_path = self.ensure_directory( + config.get("uploads_path", "uploads") + ) else: self.media_store_path = None self.uploads_path = None diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 4e62fbf32..f57b09cb9 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -1011,8 +1011,7 @@ class FederationClient(FederationBase): """ try: complexity = yield self.transport_layer.get_room_complexity( - destination=destination, - room_id=room_id + destination=destination, room_id=room_id ) defer.returnValue(complexity) except CodeMessageException as e: @@ -1020,12 +1019,13 @@ class FederationClient(FederationBase): # servers don't give it to us. logger.debug( "Failed to fetch room complexity via %s for %s, got a %d", - destination, room_id, e.code + destination, + room_id, + e.code, ) except Exception: logger.exception( - "Failed to fetch room complexity via %s for %s", - destination, room_id + "Failed to fetch room complexity via %s for %s", destination, room_id ) # If we don't manage to find it, return None. It's not an error if a diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index 8ba893ab3..ce5f510bd 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -945,14 +945,9 @@ class TransportLayerClient(object): destination (str): The remote server room_id (str): The room ID to ask about. """ - path = _create_path( - FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id - ) + path = _create_path(FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id) - return self.client.get_json( - destination=destination, - path=path - ) + return self.client.get_json(destination=destination, path=path) def _create_path(federation_prefix, path, *args): diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index cef520392..06777fefa 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -1030,8 +1030,9 @@ class RoomMemberMasterHandler(RoomMemberHandler): ) if too_complex is True: raise SynapseError( - code=400, msg=ROOM_COMPLEXITY_TOO_GREAT, - errcode=Codes.RESOURCE_LIMIT_EXCEEDED + code=400, + msg=ROOM_COMPLEXITY_TOO_GREAT, + errcode=Codes.RESOURCE_LIMIT_EXCEEDED, ) # We don't do an auth check if we are doing an invite @@ -1058,18 +1059,14 @@ class RoomMemberMasterHandler(RoomMemberHandler): return # The room is too large. Leave. - requester = types.create_requester( - user, None, False, None - ) + requester = types.create_requester(user, None, False, None) yield self.update_membership( - requester=requester, - target=user, - room_id=room_id, - action="leave" + requester=requester, target=user, room_id=room_id, action="leave" ) raise SynapseError( - code=400, msg=ROOM_COMPLEXITY_TOO_GREAT, - errcode=Codes.RESOURCE_LIMIT_EXCEEDED + code=400, + msg=ROOM_COMPLEXITY_TOO_GREAT, + errcode=Codes.RESOURCE_LIMIT_EXCEEDED, ) @defer.inlineCallbacks diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py index c7dddb2bb..9d7027b94 100644 --- a/synapse/storage/events_worker.py +++ b/synapse/storage/events_worker.py @@ -683,7 +683,9 @@ class EventsWorkerStore(SQLBaseStore): Deferred[int] """ return self.runInteraction( - "get_current_state_event_counts", self._get_current_state_event_counts_txn, room_id + "get_current_state_event_counts", + self._get_current_state_event_counts_txn, + room_id, ) def _get_current_state_event_counts_txn(self, txn, room_id): diff --git a/tests/federation/test_complexity.py b/tests/federation/test_complexity.py index c499d9d9d..a03d0cdb0 100644 --- a/tests/federation/test_complexity.py +++ b/tests/federation/test_complexity.py @@ -36,7 +36,7 @@ class RoomComplexityTests(unittest.HomeserverTestCase): login.register_servlets, ] - def default_config(self, name='test'): + def default_config(self, name="test"): config = super().default_config(name=name) config["limit_large_remote_room_joins"] = True config["limit_large_remote_room_complexity"] = 0.05