Skip to content
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

Closed
felix-hilden opened this issue Mar 23, 2021 · 4 comments
Closed

Future-proof response parsing #247

felix-hilden opened this issue Mar 23, 2021 · 4 comments
Labels
enhancement New feature or improvement
Milestone

Comments

@felix-hilden
Copy link
Owner

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 a kwargs. Since the arguments are unpacked as keywords to the constructor, a double-star would catch any unknown names.

@felix-hilden felix-hilden added the enhancement New feature or improvement label Mar 23, 2021
@felix-hilden felix-hilden added this to the v4.0.0 milestone Mar 23, 2021
@felix-hilden
Copy link
Owner Author

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.

@felix-hilden
Copy link
Owner Author

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.

@felix-hilden
Copy link
Owner Author

Implementing it is a different beast altogether then. We might have to change to attrs: python-attrs/attrs#110

@felix-hilden
Copy link
Owner Author

It is possible using dataclasses! Here's a discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

1 participant