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

Commit

Permalink
Fix some lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Feb 5, 2021
1 parent 800f3a3 commit 9b5e057
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
5 changes: 4 additions & 1 deletion synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def is_state(self):
return self._state_key is not None

async def build(
self, prev_event_ids: List[str], overriding_prev_events: False, auth_event_ids: Optional[List[str]],
self,
prev_event_ids: List[str],
overriding_prev_events: False,
auth_event_ids: Optional[List[str]],
) -> EventBase:
"""Transform into a fully signed and hashed event
Expand Down
4 changes: 3 additions & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,9 @@ async def create_new_client_event(
), "Attempting to create an event with no prev_events"

event = await builder.build(
prev_event_ids=prev_event_ids, overriding_prev_events=overriding_prev_events, auth_event_ids=auth_event_ids
prev_event_ids=prev_event_ids,
overriding_prev_events=overriding_prev_events,
auth_event_ids=auth_event_ids,
)
context = await self.state.compute_event_context(event)
if requester:
Expand Down
5 changes: 1 addition & 4 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@
from synapse.util.caches.lrucache import LruCache
from synapse.util.caches.response_cache import ResponseCache
from synapse.util.metrics import Measure, measure_func
from synapse.visibility import (
filter_events_for_client,
filter_historical_events
)
from synapse.visibility import filter_events_for_client, filter_historical_events

if TYPE_CHECKING:
from synapse.server import HomeServer
Expand Down
21 changes: 10 additions & 11 deletions synapse/http/servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,12 @@ def parse_string(
)


def parse_string_value(
value,
allowed_values,
name="",
encoding="ascii"
) -> str:
def parse_string_value(value, allowed_values, name="", encoding="ascii") -> str:
if encoding:
try:
value = value.decode(encoding)
except ValueError:
raise SynapseError(
400, "Query parameter %r must be %s" % (name, encoding)
)
raise SynapseError(400, "Query parameter %r must be %s" % (name, encoding))

if allowed_values is not None and value not in allowed_values:
message = "Query parameter %r must be one of [%s]" % (
Expand All @@ -171,6 +164,7 @@ def parse_string_value(
else:
return value


def parse_strings_from_args(
args,
name,
Expand All @@ -187,7 +181,10 @@ def parse_strings_from_args(
if name in args:
values = args[name]

return [parse_string_value(value, allowed_values, name=name, encoding=encoding) for value in values]
return [
parse_string_value(value, allowed_values, name=name, encoding=encoding)
for value in values
]
else:
if required:
message = "Missing %s query parameter %r" % (param_type, name)
Expand Down Expand Up @@ -218,13 +215,14 @@ def parse_string_from_args(
param_type=param_type,
encoding=encoding,
)

if isinstance(strings, list) and len(strings):
return strings[0]

# Return the default
return strings


def parse_json_value_from_request(request, allow_empty_body=False):
"""Parse a JSON value from the body of a twisted HTTP request.
Expand Down Expand Up @@ -279,6 +277,7 @@ def parse_json_object_from_request(request, allow_empty_body=False):

return content


def assert_params_in_dict(body, required):
absent = []
for k in required:
Expand Down
4 changes: 3 additions & 1 deletion synapse/rest/client/v1/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,14 @@ async def on_POST(self, request, room_id, event_type, txn_id=None):
"type": event_type,
"content": content,
"room_id": room_id,
"sender": requester.user.to_string()
"sender": requester.user.to_string(),
}

if prev_events:
event_dict["prev_events"] = prev_events

# TODO: Put app_service logic back in place once we figure out how to make the Complement tests
# run as an app service
if b"ts" in request.args: # and requester.app_service:
event_dict["origin_server_ts"] = parse_integer(request, "ts", 0)

Expand Down
6 changes: 3 additions & 3 deletions synapse/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
Membership.BAN,
)

async def filter_historical_events(
events
):

async def filter_historical_events(events):
filtered_events = [e for e in events if not e.content.get("m.historical", None)]

# remove the None entries
Expand All @@ -56,6 +55,7 @@ async def filter_historical_events(
# we turn it into a list before returning it.
return list(filtered_events)


async def filter_events_for_client(
storage: Storage,
user_id,
Expand Down

0 comments on commit 9b5e057

Please sign in to comment.