QuerryParams adds to URL params with "None" value #2194
Unanswered
stevstrong
asked this question in
Potential Issue
Replies: 1 comment 2 replies
-
We have different behaviour from Personally the "omit a parameter if the value is None" seems like non-intuitive behaviour to me, although I realise that folks may have different expectations here. There's a brief note here: https://www.python-httpx.org/compatibility/#query-parameters |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I used the
build_requestmethod ofAsyncClient()with the followingparams:{'start_time': 1651222800, 'end_time': None}The resulting URL looks like this:
<my_url>?start_time=1651222800&end_time=I would expect that the second key having value "None" from the
paramswill not be added at all to the URL.I tested the
prepare()method of the standard requests lib and that returns the following URL (conforming with my expectations not adding the second key as it has "None" value):<my_url>?start_time=1651222800Digging in the source files I reached these lines in
__init__method ofQueryParamsclass:httpx/httpx/_urls.py
Lines 563 to 593 in 3350d7e
Is it possible that a "None" value is not checked and excluded at all?
If yes, is that wanted?
Beta Was this translation helpful? Give feedback.
All reactions