feat: Strict keyword handling in request methods#65
Merged
Conversation
All request methods on Relation accept params and headers as keyword
arguments only. This clearly separates them from any data.
This needs changes to users, for example:
get({}, {headers: ...}) -> get(headers: ...)
head(params) -> head(params:)
The methods #post, #put, and #patch still take an optional first
positional data/body argument:
post(body, {}, {headers: ...}) -> post(body, headers: ...)
patch(body, {q: 1}) -> post(body, params: {q: 1})
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
==========================================
+ Coverage 95.40% 95.87% +0.46%
==========================================
Files 21 21
Lines 675 678 +3
==========================================
+ Hits 644 650 +6
+ Misses 31 28 -3 ☔ View full report in Codecov by Sentry. |
774ac38 to
536fe77
Compare
These are merged with the keyword argument params, with the latter being
preferred. This allows writing shorter methods, such as:
gh.rel(:user).get({user: 'jgraichen'}).value!
The commit further expands the testing on the request methods, for
params and data handling.
536fe77 to
96b9abc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All request methods on Relation accept parameters and headers as keyword arguments. This clearly separates them from any data. They continue to take either
paramsordataas a positional argument too, to support shorter call invocations.This needs changes to users, for example:
These can stay:
The methods
#post,#put, and#patchstill take an optional first positional data/body argument: