]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Support QueryParams(None) (#1060)
authorTom Christie <tom@tomchristie.com>
Thu, 16 Jul 2020 10:16:29 +0000 (11:16 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Jul 2020 10:16:29 +0000 (11:16 +0100)
httpx/_client.py
httpx/_models.py
httpx/_types.py
tests/models/test_queryparams.py

index 35d0bd0fe53dbc3427943712b7a2cf1c70bc294e..80a2bb03c33783209cdaad84e2c439a3c2d7bd07 100644 (file)
@@ -73,9 +73,6 @@ class BaseClient:
         else:
             self.base_url = URL(base_url)
 
-        if params is None:
-            params = {}
-
         self.auth = auth
         self._params = QueryParams(params)
         self._headers = Headers(headers)
index bf5f6d1cdd40011badeca36b7328ce5acab848b5..1ab162cd65d82f02db059bd5305761f4e48bbfeb 100644 (file)
@@ -287,7 +287,7 @@ class QueryParams(typing.Mapping[str, str]):
         value = args[0] if args else kwargs
 
         items: typing.Sequence[typing.Tuple[str, PrimitiveData]]
-        if isinstance(value, str):
+        if value is None or isinstance(value, str):
             items = parse_qsl(value)
         elif isinstance(value, QueryParams):
             items = value.multi_items()
index d2fc098e249f1104fc5250c78f710fc01d650a31..bfce5650dad6934f9c1c00fe8f212a2cb7d74bb0 100644 (file)
@@ -34,6 +34,7 @@ QueryParamTypes = Union[
     Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]],
     List[Tuple[str, PrimitiveData]],
     str,
+    None,
 ]
 
 HeaderTypes = Union[
index 0b0101cb310d97d1fbb4bf1f4acbf74ad4ac8c4e..99f193f86d9091830b24425fd2dd45c17ad58c96 100644 (file)
@@ -44,6 +44,9 @@ def test_queryparams(source):
 
 
 def test_queryparam_types():
+    q = QueryParams(None)
+    assert str(q) == ""
+
     q = QueryParams({"a": True})
     assert str(q) == "a=true"