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

Commit

Permalink
Add type hints to additional servlet functions (#10437)
Browse files Browse the repository at this point in the history
Improves type hints for:

* parse_{boolean,integer}
* parse_{boolean,integer}_from_args
* parse_json_{value,object}_from_request

And fixes any incorrect calls that resulted from unknown types.
  • Loading branch information
clokep authored Jul 21, 2021
1 parent 5b68816 commit 590cc4e
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 66 deletions.
1 change: 1 addition & 0 deletions changelog.d/10437.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve servlet type hints.
13 changes: 2 additions & 11 deletions synapse/federation/transport/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ async def on_GET(
limit = parse_integer_from_args(query, "limit", 0)
since_token = parse_string_from_args(query, "since", None)
include_all_networks = parse_boolean_from_args(
query, "include_all_networks", False
query, "include_all_networks", default=False
)
third_party_instance_id = parse_string_from_args(
query, "third_party_instance_id", None
Expand Down Expand Up @@ -1908,16 +1908,7 @@ async def on_GET(
suggested_only = parse_boolean_from_args(query, "suggested_only", default=False)
max_rooms_per_space = parse_integer_from_args(query, "max_rooms_per_space")

exclude_rooms = []
if b"exclude_rooms" in query:
try:
exclude_rooms = [
room_id.decode("ascii") for room_id in query[b"exclude_rooms"]
]
except Exception:
raise SynapseError(
400, "Bad query parameter for exclude_rooms", Codes.INVALID_PARAM
)
exclude_rooms = parse_strings_from_args(query, "exclude_rooms", default=[])

return 200, await self.handler.federation_space_summary(
origin, room_id, suggested_only, max_rooms_per_space, exclude_rooms
Expand Down
Loading

0 comments on commit 590cc4e

Please sign in to comment.