Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-117941: Fix argparse issue-Changed call method of BooleanOptionalAction class in argparse.py #117941#118103
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedApr 19, 2024 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
I was wondering if when does it review. |
encukou left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
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.
The PR needs tests and documentation for the new behaviour.
However, I'm not convinced that we should do this; I think it would be better to deprecate adding boolean options that start with--no-. The auto-added--no-no- option itself is surprising.
| @@ -0,0 +1 @@ | |||
| write! | |||
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.
Please seethe devguide on how to write a NEWS entry.
Thank you for answer my question. I understand your explanation. But I think that to eliminating exception or abnormal situation is very important. In that sense, isn't it better to fix the code? |
If you can fix it properly, sure. It will not be easy. On the other hand, if we clearly say that adding |
Oh, thank you for your answer. I have one question. If the option string starts with "--no-" I think the current BoolOptionalAction always returns "False". What do you think about this? |
Right; I don't think that was the intent. >>>import argparse>>> parser= argparse.ArgumentParser()>>> parser.add_argument('--no-foo',default=True,action=argparse.BooleanOptionalAction)>>> parser.parse_args()Namespace(no_foo=True)>>> parser.parse_args(['--no-foo'])Namespace(no_foo=False) The documentation doesn't clearly say that this is wrong:
|
Uh oh!
There was an error while loading.Please reload this page.