You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, filter syntax directly overlaps with f-string syntax. This make string building URLs a little more cumbersome:
importhttpxdefget_user_from_substring(sub_name: str):
# I would like to use f-string in URL, but this collides with filter syntaxresponse=httpx.get(f"/users/?filter{name.icontains}={sub_name}")
...
defget_user_from_substring(sub_name: str):
# Workaround 1: use `__add__`response=httpx.get("/users/?filter{name.icontains}="+sub_name)
# Workaround 2: use double curlyresponse=httpx.get(f"/users/?filter{{name.icontains}}={sub_name}")
# Workaround 3: use string concatenation (black autoformats this to Workaround 2)response=httpx.get(
"/users/?filter{name.icontains}="f"{sub_name}"
)
...
Can we support an alternate syntax for filter strings, so one can avoid the workarounds? Perhaps []
The text was updated successfully, but these errors were encountered:
Thanks for asking for clarification. I wrote it in the original post, but to restate more concisely, it's to avoid overlap with f-strings:
# Here is an f-string and filter syntax collision, which will lead to a bughttpx.get(f"/users/?filter{name.icontains}={sub_name}")
# Here is a workaround (requires knowing about the possible collision) to avoid the bughttpx.get(f"/users/?filter{{name.icontains}}={sub_name}")
# What I am asking for (or something like this): configurability to avoid f-string syntax collisionhttpx.get(f"/users/?filter[name.icontains]={sub_name}")
Currently, filter syntax directly overlaps with f-string syntax. This make string building URLs a little more cumbersome:
Can we support an alternate syntax for filter strings, so one can avoid the workarounds? Perhaps
[]
The text was updated successfully, but these errors were encountered: