Currently, filter syntax directly overlaps with f-string syntax. This make string building URLs a little more cumbersome:
import httpx
def get_user_from_substring(sub_name: str):
# I would like to use f-string in URL, but this collides with filter syntax
response = httpx.get(f"/users/?filter{name.icontains}={sub_name}")
...
def get_user_from_substring(sub_name: str):
# Workaround 1: use `__add__`
response = httpx.get("/users/?filter{name.icontains}=" + sub_name)
# Workaround 2: use double curly
response = 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 []