question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change QueryParams(key=None) to not emit a parameter

See original GitHub issue

This one I know is requests behaviour:

Take a dict:

>>> from httpx import QueryParams
>>> params = {"thing_one": 1, "thing_two": [1,2,3], "thing_three": None}
>>> QueryParams(params)
QueryParams('thing_one=1&thing_two=%5B1%2C+2%2C+3%5D&thing_three=None')

Expected:

QueryParams('thing_one=1&thing_two=%5B1%2C+2%2C+3%5D')

Adding if v is not None here will do it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sethmlarsoncommented, Jul 29, 2019

Since I’m no longer on mobile and can type symbols easily I’m proposing:

  • {"q": "1"} -> ?q=1
  • {"q": ""} -> ?q=
  • {"q": None} -> ?q

There are also instances where the order matters for the parameters, so maybe we need to allow typing.Iterable[typing.Tuple[typing.AnyStr, typing.AnyStr]] in addition to dict?

0reactions
StephenBrown2commented, Jul 29, 2019

I’m using Pydantic to roundtrip my params and standardize on values with custom validators/parsers: https://pydantic-docs.helpmanual.io/#json-serialisation so I’m sure some inspiration could be taken from that.

I would not be opposed to the latter, especially since query params can imitate form data, they should also allow lists, and explode them since QueryParams is already a multi-dict. This however could be left up to the user.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular: How to update queryParams without changing route
You can navigate to the current route with new query params, which will not reload your page, but will update query params. Something...
Read more >
Validate Query Parameters and Headers Using APIkit
Validate Query Parameters and Headers Using APIkit · In your Studio canvas, select APIkit Router. · Select the Edit button for your router...
Read more >
Power BI October 2020 Feature Summary
This new Microsoft Power BI feature allows M Query Parameters to be ... Note that if the mapped column is set to No...
Read more >
Prometheus data source | Grafana documentation
Set the data source's basic configuration options carefully: ... Custom query parameters, Adds custom parameters to the Prometheus query URL, ...
Read more >
RestEase.SourceGenerator 1.6.1 - NuGet
Formatting Variable Query Parameters; Serialization of Variable Query Parameters ... ISomeApi { [Header("X-API-Key", "None")] string ApiKey { get; set; } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found