Skip to content

Response keyword boolean #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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pusewicz
Copy link
Contributor

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

response = Response.new(content, true) # What is true?

After

response = Response.new(content, error: true)

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

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!

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)
```
Rather than passing a boolean flag to the response, introduce an
`ErrorResponse` class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant