Fix possible types for json parameter to Route.respond#290
Fix possible types for json parameter to Route.respond#290viccie30 wants to merge 1 commit intolundberg:masterfrom
Conversation
|
You're right @viccie30, though we need to align with the Looks like httpx is typing json as Also, the python docs you're referring to touches encoding, e.g. python accepts tuples when dumping to json, but the response we're talking about here is about a loaded/decoded json ... >>> json.loads(json.dumps(("httpx", "respx")))
['httpx', 'respx'] |
|
Looks like we've diverged from httpx on the request/encoding side as well .. also typed as |
Oh right, because this is mocking the returned value of httpx.Response's json property. I think you're right therefore to copy httpx's annotations. |
Yes, let's change to About the request/encoding side, I think we're fine with current typing. We're mimicking httpx api there as well, but we're not patching/mocking, but rather pattern matching encoded request json. |
|
The current state of the art: |
Might be worth discussing, but since Sticking with how httpx is typed is probably what we're "forced" to do .. maybe take your suggestion to a httpx and discuss the |
According to the Python documentation, more than just strings, dicts, and lists can be encoded to JSON.