-
Notifications
You must be signed in to change notification settings - Fork 59
Response error keyword argument #107
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
Response error keyword argument #107
Conversation
e26451d
to
10aa055
Compare
|
||
response = Response.new(content) | ||
assert_equal content, response.content | ||
refute response.error? |
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.
Can you split it into three tests, each independently executable per assertion group?
actual = response.to_h | ||
assert_equal [:content, :isError].sort, actual.keys.sort | ||
assert_equal content, actual[:content] | ||
assert actual[:isError] |
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.
Can you split it into two tests, each independently executable per assertion group?
test/mcp/tool/response_test.rb
Outdated
assert response.error? | ||
|
||
response = Response.new(nil, error: false) | ||
refute response.error? |
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.
Can you split it into two tests, each independently executable per assertion?
test/mcp/tool/response_test.rb
Outdated
|
||
response = Response.new(nil, error: false) | ||
refute response.error? | ||
end |
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.
Can you move this test "#error?" do
(L46-L52) before test "#to_h" do
(L27) ?
Since the purpose of these changes is singular, please squash them into a single commit. |
Both the combination of positional argument and naming does not feel like Ruby. This change makes `is_error` argument a keyword argument called `error`. Thanks to this, the usage is more self-explanatory: ```ruby response = Response.new([], error: true) ```
10aa055
to
6689db2
Compare
@koic Addressed your feedback. |
The positional argument and naming is a bit awkward, and feels unnatural. Let's instead follow the Ruby style and add an
error:
keyword argument.Before
After
Motivation and Context
How Has This Been Tested?
Unit tests
Breaking Changes
For anyone using the positional argument, this is a breaking change.
Types of changes
Checklist
Additional context
I'm happy to remove the second commit that introduces the
ErrorResponse
class. I do find it's usage a nicer approach that moves the decision to the caller, but also I can see how it adds some unnecessary boilerplate. Let me know what you think!