New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Future-proof response parsing #247
Comments
It's could also be convenient if the uncaught attributes would still be available with dot notation. I think it would be fine if undocumented attributes are not in the dataclass spec, but not being able to print them or serialise them is a bit of a problem. |
A drawback of this approach would be that we don't get any information on added attributes, undocumented or documented, unless we watch over the Web API reference. So on second thought I'm thinking maybe we shouldn't do this after all. Adding attributes should be pretty uncommon. |
Implementing it is a different beast altogether then. We might have to change to |
It is possible using dataclasses! Here's a discussion. |
Tekore parses responses into nested, type-hinted dataclasses by design to remove some guesswork from users when it comes to interacting with the API.
There are issues however, as additions are not always announced or documented, like in #246. It would be good to have some way of avoiding fails in the response parsing when new things are added. I still think that it should fail if things are removed though.
One way this could be done would be classes whose
init
contains akwargs
. Since the arguments are unpacked as keywords to the constructor, a double-star would catch any unknown names.The text was updated successfully, but these errors were encountered: