Using TypedDict to type check **kwargs #3123
igorp-collabora
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
|
I'm a bit torn on this, because being able to provide API parameters for arbitrary endpoints directly as function arguments makes this library more convenient to use and the user code more pythonic. On the other hand I assume without moving to |
Beta Was this translation helpful? Give feedback.
3 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.
-
Currently the most of the methods that have an underlying HTTP request takes a
**kwargs: Anyarguments that passed down to the HTTP handling functions. For example, it can betimeoutorextra_headers.However, because they are using
Anythere is no type checking on the arguments used. This means a wrong argument name can be used.To type hint
**kwargsaTypedDictcombined withUnpackcan be used:https://peps.python.org/pep-0692/
https://docs.python.org/3/library/typing.html#typing.Unpack
One of the issues implementing this can be that all unused
kwargswill be converted in to an HTTP query args in thehttp_requestfunction. However, there is already aquery_parametersargument that was added to avoid collisions. Maybe make thequery_parametersthe official way of adding extra http query and leave the extra kwargs only for backwards compatibility.Beta Was this translation helpful? Give feedback.
All reactions