Skip to content

Commit

Permalink
Support QueryParams(None) (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie authored Jul 16, 2020
1 parent ccd4711 commit ff93a01
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions httpx/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ def __init__(
else:
self.base_url = URL(base_url)

if params is None:
params = {}

self.auth = auth
self._params = QueryParams(params)
self._headers = Headers(headers)
Expand Down
2 changes: 1 addition & 1 deletion httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__(self, *args: QueryParamTypes, **kwargs: typing.Any) -> None:
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()
Expand Down
1 change: 1 addition & 0 deletions httpx/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]],
List[Tuple[str, PrimitiveData]],
str,
None,
]

HeaderTypes = Union[
Expand Down
3 changes: 3 additions & 0 deletions tests/models/test_queryparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit ff93a01

Please sign in to comment.