Skip to content
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

[query] Add or_error method to SwitchBuilder #9749

Merged
merged 1 commit into from Nov 30, 2020

Conversation

nawatts
Copy link
Contributor

@nawatts nawatts commented Nov 30, 2020

CaseBuilder has an or_error method to throw an error if no when conditions are true. Currently, SwitchBuilder does not have an equivalent method: it only supports returning a default value or missing. The option to throw an error on an unhandled value can be useful for making sure that all possible values for an enum expression have been accounted for in switch cases.

@@ -83,7 +83,7 @@ def f(base):
@typecheck_method(value=expr_any, then=expr_any)
def when(self, value, then) -> 'SwitchBuilder':
"""Add a value test. If the `base` expression is equal to `value`, then
returns `then`.
returns `then`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated formatting fix for SwitchBuilder.when docs.

Copy link
Contributor

@johnc1231 johnc1231 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good addition. The one thing I'd say is just that when we make a user facing change, we try to make one of the commits look like:

CHANGELOG: Added or_error method to SwitchBuilder

This ends up being helpful when I have to go through and generate the change log for a new version release.

@johnc1231 johnc1231 changed the title Add or_error method to SwitchBuilder [query] Add or_error method to SwitchBuilder Nov 30, 2020
@nawatts
Copy link
Contributor Author

nawatts commented Nov 30, 2020

The one thing I'd say is just that when we make a user facing change, we try to make one of the commits look like:

CHANGELOG: Added or_error method to SwitchBuilder

This ends up being helpful when I have to go through and generate the change log for a new version release.

Good to know, updated the commit message. It would be nice to document conventions like this in the docs for software developers and/or a contributing file.

@johnc1231
Copy link
Contributor

This is a good point, we should look into doing that. Thanks for the suggestion.

@danking danking merged commit 4ffeb0b into hail-is:main Nov 30, 2020
@nawatts
Copy link
Contributor Author

nawatts commented Dec 1, 2020

Added the "CHANGELOG" note to contribution guidelines in #9752.

@nawatts nawatts deleted the switch-or-error branch December 1, 2020 16:50
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.

None yet

3 participants