* Raise TypeError on invalid query params
* Fix TypeError
* Update tests/models/test_queryparams.py
Co-authored-by: Michael Adkins <contact@zanie.dev>
* Linting
* Fix exception check
Co-authored-by: Michael Adkins <contact@zanie.dev>
return "false"
elif value is None:
return ""
- return str(value)
+ elif isinstance(value, (str, float, int)):
+ return str(value)
+ raise TypeError(
+ f"Expected str, int, float, bool, or None. Got {type(value).__name__!r}."
+ )
def is_known_encoding(encoding: str) -> bool:
assert str(q) == "a="
+def test_invalid_query_params():
+ with pytest.raises(
+ TypeError, match=r"Expected str, int, float, bool, or None. Got 'bytes'."
+ ):
+ httpx.QueryParams({"a": b"bytes"})
+
+
def test_queryparam_update_is_hard_deprecated():
q = httpx.QueryParams("a=123")
with pytest.raises(RuntimeError):