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
Replace query params in url with params in get #6
Conversation
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.
I agree! Great call, just want to verify that you ensured it works - we currently have a lack of integration testing/CI :(
@asheidan I've added POST to this class. I like this change would you update your PR to account for POST as well? |
Regarding testing: Regarding post: I’ll try to make time for this this evening (UTC+2). |
This will have the upside that there is a single implementation for (de-)serialization and parameter checking. This also moves the serialization for query parameters to the requests library.
3228530
to
694e672
Compare
I've looked at the newly added methods in pybuildkite.client.Client. Since the new functions adds quite a lot of code duplication I've extracted the actual call to requests to a separate method where you can handle all common scenarios instead. As I'm not sure if there's a good reason for having separate methods for the different HTTP-verbs in this particular domain, feel free to just close my PR and just use the code from Client.request() in my branch in the other functions. |
I will not be able to merge this unless we change all existing functionality to subscribe to this new pattern. I’m not sure I’m comfortable with having to put a string for each request. I do however like the consolidation: what about a method in the client for each verb that then passes info to a common request function. This way the classes still call the client.post() directly but the client itself makes any necessary changes and routes it to a request method |
Isn't your suggestion the same as my solution? If you check my implementation of Client.get(): I was unsure if my solution (with just shims calling Client.request() for each verb would work) or if there were specific needs not yet implemented which needed the totally separated implementations. |
Oh sorry, yes- I was on mobile. This looks great! Thanks for the contribution |
This replaces the previous implementation of manually calling encoding query params with urlencode with
requests.get(url, params=params, ...)
.This moves the responsibility of encoding the query parameters to the requests library.
Less responsibility is usually better! ;)