-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-38956: remove default option from help string in argparse #17447
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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 hidden or 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
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.
I think the effect of this edit is too broad. Instead, focus on making sure the default only prints once when the formatter_class is set to ArgumentDefaultsHelpFormatter. When formatter_class isn't set, the default still needs to be shown.
Given this script:
We still want this output:
Uh oh!
There was an error while loading. Please reload this page.
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 have made the requested changes; please review again
Hi I have updated the code in add action function since it is not possible to get formatter class in action object, ArgumentDefaultsHelpFormatter already add default value and that was the origin problem which result in duplicate default value in the help string. Now with the default formatter class it can also show the default value.
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.
Hey @rhettinger could you speak on why the default should be displayed for BooleanOptionalArgument out-of-the-box whereas all other shipped actions require setting
formatter_class=ArgumentDefaultsHelpFormatter? I do find that showing the default value is useful but it seems to break the expected separation of responsibility between action and formatter.I ask about this since I have a different bug which would be fixed if BooleanOptionalArgument were to no longer try to add defaults on its own. If BooleanOptionalArgument should continue to do that formatting, though, I could extract the code from ArgumentDefaultsHelpFormatter and have both ArgumentDefaultsHelpFormatter and BooleanOptionalArgument use it which would likely fix my issue, this issue, and a similar class of issues that we just haven't encountered yet.