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

Commit

Permalink
Remove double return statements (#5962)
Browse files Browse the repository at this point in the history
Remove all the "double return" statements which were a result of us removing all the instances of

```
defer.returnValue(...)
return
```

statements when we switched to python3 fully.
  • Loading branch information
anoadragon453 authored Sep 3, 2019
1 parent a90d16d commit 2a44782
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 20 deletions.
1 change: 1 addition & 0 deletions changelog.d/5962.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unnecessary return statements in the codebase which were the result of a regex run.
1 change: 0 additions & 1 deletion synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ def check_in_room_or_world_readable(self, room_id, user_id):
and visibility.content["history_visibility"] == "world_readable"
):
return Membership.JOIN, None
return
raise AuthError(
403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN
)
Expand Down
3 changes: 0 additions & 3 deletions synapse/appservice/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def query_user(self, service, user_id):
except CodeMessageException as e:
if e.code == 404:
return False
return
logger.warning("query_user to %s received %s", uri, e.code)
except Exception as ex:
logger.warning("query_user to %s threw exception %s", uri, ex)
Expand All @@ -127,7 +126,6 @@ def query_alias(self, service, alias):
logger.warning("query_alias to %s received %s", uri, e.code)
if e.code == 404:
return False
return
except Exception as ex:
logger.warning("query_alias to %s threw exception %s", uri, ex)
return False
Expand Down Expand Up @@ -230,7 +228,6 @@ def push_bulk(self, service, events, txn_id=None):
sent_transactions_counter.labels(service.id).inc()
sent_events_counter.labels(service.id).inc(len(events))
return True
return
except CodeMessageException as e:
logger.warning("push_bulk to %s received %s", uri, e.code)
except Exception as ex:
Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,10 @@ def _is_unknown_user(self, user_id):
# we don't know if they are unknown or not since it isn't one of our
# users. We can't poke ASes.
return False
return

user_info = yield self.store.get_user_by_id(user_id)
if user_info:
return False
return

# user not found; could be the AS though, so check.
services = self.store.get_app_services()
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def get_event(self, user, room_id, event_id):

if not event:
return None
return

users = yield self.store.get_users_in_room(event.room_id)
is_peeking = user.to_string() not in users
Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ def _check_in_room_or_world_readable(self, room_id, user_id):
# else it will throw.
member_event = yield self.auth.check_user_was_in_room(room_id, user_id)
return member_event.membership, member_event.event_id
return
except AuthError:
visibility = yield self.state_handler.get_current_state(
room_id, EventTypes.RoomHistoryVisibility, ""
Expand All @@ -460,7 +459,6 @@ def _check_in_room_or_world_readable(self, room_id, user_id):
and visibility.content["history_visibility"] == "world_readable"
):
return Membership.JOIN, None
return
raise AuthError(
403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN
)
1 change: 0 additions & 1 deletion synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,6 @@ def filter_evts(events):
)
if not event:
return None
return

filtered = yield (filter_evts([event]))
if not filtered:
Expand Down
1 change: 0 additions & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ def compute_summary(self, room_id, sync_config, batch, state, now_token):

if not last_events:
return None
return

last_event = last_events[-1]
state_ids = yield self.store.get_state_ids_for_event(
Expand Down
1 change: 0 additions & 1 deletion synapse/rest/client/v1/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ def on_POST(self, request, room_id, membership_action, txn_id=None):
txn_id,
)
return 200, {}
return

target = requester.user
if membership_action in ["invite", "ban", "unban", "kick"]:
Expand Down
2 changes: 0 additions & 2 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def on_POST(self, request):
if kind == b"guest":
ret = yield self._do_guest_registration(body, address=client_addr)
return ret
return
elif kind != b"user":
raise UnrecognizedRequestError(
"Do not understand membership kind: %s" % (kind,)
Expand Down Expand Up @@ -280,7 +279,6 @@ def on_POST(self, request):
desired_username, access_token, body
)
return 200, result # we throw for non 200 responses
return

# for regular registration, downcase the provided username before
# attempting to register it. This should mean
Expand Down
1 change: 0 additions & 1 deletion synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def _do_preview(self, url, user, ts):
if isinstance(og, six.text_type):
og = og.encode("utf8")
return og
return

media_info = yield self._download_url(url, user)

Expand Down
1 change: 0 additions & 1 deletion synapse/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def get_current_state(
if event_id:
event = yield self.store.get_event(event_id, allow_none=True)
return event
return

state_map = yield self.store.get_events(
list(state.values()), get_prev_content=False
Expand Down
1 change: 0 additions & 1 deletion synapse/storage/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def get_appservice_state(self, service):
)
if result:
return result.get("state")
return
return None

def set_appservice_state(self, service, state):
Expand Down
2 changes: 0 additions & 2 deletions synapse/storage/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def get_association_from_room_alias(self, room_alias):

if not room_id:
return None
return

servers = yield self._simple_select_onecol(
"room_alias_servers",
Expand All @@ -58,7 +57,6 @@ def get_association_from_room_alias(self, room_alias):

if not servers:
return None
return

return RoomAliasMapping(room_id, room_alias.to_string(), servers)

Expand Down
1 change: 0 additions & 1 deletion synapse/storage/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def get_profileinfo(self, user_localpart):
if e.code == 404:
# no match
return ProfileInfo(None, None)
return
else:
raise

Expand Down

0 comments on commit 2a44782

Please sign in to comment.