-
Notifications
You must be signed in to change notification settings - Fork 182
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
docs(rest_client): note about data_selector
#2101
Conversation
✅ Deploy Preview for dlt-hub-docs canceled.
|
Hey @joscha you're absolutely right. I'd say it should not be in |
Do you want me to remove it from Rest client? It is a breaking change, albeit a super easy fix. Alternatively I could deprecate it instead and leave the comment in this PR. |
Let's deprecate it now (with the DeprecationWarning) and we'll remove it with the next major release. |
Okay. Will update the PR. |
Whilst doing the update I just realized that this was probably introduced for convenience. Like for example an API with lots of paginated endpoints that all follow the same pattern. It allows to do something like: rest_client = RESTClient(..., data_selector="data")
yield from rest_client.paginate("a")
yield from rest_client.paginate("b")
yield from rest_client.paginate("c")
...
yield from rest_client.paginate("x") without having to pass the rest_client = RESTClient(...)
yield from rest_client.paginate("a", data_selector="data")
yield from rest_client.paginate("b", data_selector="data")
yield from rest_client.paginate("c", data_selector="data")
...
yield from rest_client.paginate("x", data_selector="data") Which is definitely more brittle and less DRY. |
Yes, also makes sense. Let's do that. I have a suggestion to adjust the wording though. |
Co-authored-by: Anton Burnashev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @joscha!
I personally think it's a bug and
should be called automatically for all requests (
.get(...).json()
, ...) when given (1), however it would be a breaking change, so updating the documentation is the next best thing.Might also be possibly worth deprecating the parameter from the global
RESTClient
constructor, given the fact that it is only used inside.paginate(...)
(2).Let me know if you want me to open a pull request for (1) and/or (2) instead of this one.