diff --git a/httpx/_api.py b/httpx/_api.py index 985e2ab938..8cfaf6dfda 100644 --- a/httpx/_api.py +++ b/httpx/_api.py @@ -47,7 +47,7 @@ def request( `HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`. * **url** - URL for the new `Request` object. * **params** - *(optional)* Query parameters to include in the URL, as a - string, dictionary, or list of two-tuples. + string, dictionary, or sequence of two-tuples. * **content** - *(optional)* Binary content to include in the body of the request, as bytes or a byte iterator. * **data** - *(optional)* Form data to include in the body of the request, diff --git a/httpx/_client.py b/httpx/_client.py index 0ae5f2b1fa..4f457c79dc 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -520,7 +520,7 @@ class Client(BaseClient): * **auth** - *(optional)* An authentication class to use when sending requests. * **params** - *(optional)* Query parameters to include in request URLs, as - a string, dictionary, or list of two-tuples. + a string, dictionary, or sequence of two-tuples. * **headers** - *(optional)* Dictionary of HTTP headers to include when sending requests. * **cookies** - *(optional)* Dictionary of Cookie items to include when @@ -1161,7 +1161,7 @@ class AsyncClient(BaseClient): * **auth** - *(optional)* An authentication class to use when sending requests. * **params** - *(optional)* Query parameters to include in request URLs, as - a string, dictionary, or list of two-tuples. + a string, dictionary, or sequence of two-tuples. * **headers** - *(optional)* Dictionary of HTTP headers to include when sending requests. * **cookies** - *(optional)* Dictionary of Cookie items to include when diff --git a/httpx/_models.py b/httpx/_models.py index a77f7a5790..2d11888254 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -441,7 +441,7 @@ def __init__(self, *args: QueryParamTypes, **kwargs: typing.Any) -> None: items = parse_qsl(value) elif isinstance(value, QueryParams): items = value.multi_items() - elif isinstance(value, list): + elif isinstance(value, (list, tuple)): items = value else: items = flatten_queryparams(value) diff --git a/httpx/_types.py b/httpx/_types.py index 776df1d8dc..7768bac11b 100644 --- a/httpx/_types.py +++ b/httpx/_types.py @@ -35,6 +35,7 @@ "QueryParams", Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]], List[Tuple[str, PrimitiveData]], + Tuple[Tuple[str, PrimitiveData], ...], str, bytes, None, diff --git a/tests/models/test_queryparams.py b/tests/models/test_queryparams.py index d591eded8c..7031a65cb9 100644 --- a/tests/models/test_queryparams.py +++ b/tests/models/test_queryparams.py @@ -9,6 +9,8 @@ "a=123&a=456&b=789", {"a": ["123", "456"], "b": 789}, {"a": ("123", "456"), "b": 789}, + [("a", "123"), ("a", "456"), ("b", "789")], + (("a", "123"), ("a", "456"), ("b", "789")), ], ) def test_queryparams(source):