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

Commit

Permalink
I think encode_query_args is redundant.
Browse files Browse the repository at this point in the history
Rich thought that `QueryParams` is good enough to pass into
urlencode (in #8372). It seems that `urlencode` has accepted its query
parameters as strings or bytes since Python 3.2.
  • Loading branch information
David Robertson committed Apr 7, 2022
1 parent 2950867 commit 904d57f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def read_body_with_max_size(
return d


def encode_query_args(args: Optional[Mapping[str, Union[str, List[str]]]]) -> bytes:
def encode_query_args(args: Optional[QueryParams]) -> bytes:
"""
Encodes a map of query arguments to bytes which can be appended to a URL.
Expand All @@ -920,13 +920,7 @@ def encode_query_args(args: Optional[Mapping[str, Union[str, List[str]]]]) -> by
if args is None:
return b""

encoded_args = {}
for k, vs in args.items():
if isinstance(vs, str):
vs = [vs]
encoded_args[k] = [v.encode("utf8") for v in vs]

query_str = urllib.parse.urlencode(encoded_args, True)
query_str = urllib.parse.urlencode(args, True)

return query_str.encode("utf8")

Expand Down

0 comments on commit 904d57f

Please sign in to comment.