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

Call parser.error properly #3858

Merged
merged 2 commits into from Aug 16, 2022
Merged

Call parser.error properly #3858

merged 2 commits into from Aug 16, 2022

Conversation

mguaypaq
Copy link
Member

This PR removes the raise parser.error(...) anti-pattern from the codebase.

The function parser.error() from argparse never returns with a value; it either exits the program, or raises an exception. There's no need to raise the non-existent return value.

All other raise statements look like they raise actual exceptions (maybe not always the most appropriate one, but at least an exception). While checking this, I couldn't ignore two cases of raise Exception(TypeError), so I fixed those as well.

This function never returns with a value; it either exits the
program, or raises an exception. There's no need to raise the
non-existent return value.
@mguaypaq mguaypaq added sct_process_segmentation context: sct_dmri_moco context: sct_fmri_moco context: sct_maths context: sct_compute_snr context: refactoring category: improves code structure without affecting user-facing functionality SCT API: resampling.py context: labels Aug 16, 2022
@mguaypaq mguaypaq added this to the 5.8 milestone Aug 16, 2022
@mguaypaq mguaypaq self-assigned this Aug 16, 2022
@mguaypaq mguaypaq merged commit 9887249 into master Aug 16, 2022
@mguaypaq mguaypaq deleted the mgp/raise-parser-error branch August 16, 2022 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring category: improves code structure without affecting user-facing functionality SCT API: resampling.py context: sct_compute_snr context: sct_dmri_moco context: sct_fmri_moco context: sct_maths context: sct_process_segmentation context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants