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

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Jul 5, 2019
1 parent a1de642 commit 400bc06
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
8 changes: 6 additions & 2 deletions synapse/config/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ def read_config(self, config, **kwargs):
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
Expand Down
10 changes: 5 additions & 5 deletions synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,21 +1011,21 @@ def get_room_complexity(self, destination, room_id):
"""
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:
# We didn't manage to get it -- probably a 404. We are okay if other
# 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
Expand Down
9 changes: 2 additions & 7 deletions synapse/federation/transport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,9 @@ def get_room_complexity(self, destination, room_id):
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):
Expand Down
19 changes: 8 additions & 11 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,9 @@ def _remote_join(self, requester, remote_room_hosts, room_id, user, content):
)
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
Expand All @@ -1058,18 +1059,14 @@ def _remote_join(self, requester, remote_room_hosts, room_id, user, content):
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
Expand Down
4 changes: 3 additions & 1 deletion synapse/storage/events_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ def get_current_state_event_counts(self, room_id):
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):
Expand Down
2 changes: 1 addition & 1 deletion tests/federation/test_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 400bc06

Please sign in to comment.