-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[symilar] Migrate from getopt to argparse #9731
Merged
Pierre-Sassoulas
merged 5 commits into
main
from
migrate-from-getopt-to-argparse-in-symilar
Aug 25, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e187d5d
[symilar] Migrate from optparse / getopt to argparse
Pierre-Sassoulas c7aac2c
Update doc/whatsnew/fragments/9731.user_action
Pierre-Sassoulas 757d123
Remove debug print
Pierre-Sassoulas 812664a
Add help in argparse for similarity too
Pierre-Sassoulas ed1b787
Fix and move comment
Pierre-Sassoulas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
We migrated ``symilar`` to argparse, from getopt, so the error and help output changed | ||
(for the better). We exit with 2 instead of sometime 1, sometime 2. The error output | ||
is not captured by the runner anymore. It's not possible to use a value for the | ||
boolean options anymore (``--ignore-comments 1`` should become ``--ignore-comments``). | ||
|
||
Refs #9731 |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
This could be out of scope of this PR, but could it be helpful to add a couple more unit tests?
--i
could be useful because it's ambiguous andargparse
allows abbreviation (allow_abbrev
defaults toTrue
)--ignore-comments 1
as you mentioned this in the fragments).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.
All of those test cases are going to fail with an elegant argparse message. We had a lot of unit tests because we were using getopt and doing too much ourselves (no other choices at time of implementation, as argparse was not builtin yet). I added test previously to check that I wasn't changing the behavior with the migration. I don't know if we should remove tests because we trust argparse now, maybe later (?)
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.
I see. Makes sense! Yeah, seeing as a lot of this error handling gets offloaded to
argparse
, I think it sounds like it would make sense to remove the tests when ready.