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

Commit 776efc5

Browse files
author
David Robertson
committed
I think encode_query_args is redundant.
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.
1 parent 86de578 commit 776efc5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

synapse/http/client.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def read_body_with_max_size(
907907
return d
908908

909909

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

923-
encoded_args = {}
924-
for k, vs in args.items():
925-
if isinstance(vs, str):
926-
vs = [vs]
927-
encoded_args[k] = [v.encode("utf8") for v in vs]
928-
929-
query_str = urllib.parse.urlencode(encoded_args, True)
923+
query_str = urllib.parse.urlencode(args, True)
930924

931925
return query_str.encode("utf8")
932926

0 commit comments

Comments
 (0)