-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-117941: Reject option names starting with "--no-" in argparse.BooleanOptionalAction #125894
gh-117941: Reject option names starting with "--no-" in argparse.BooleanOptionalAction #125894
Conversation
…e.BooleanOptionalAction They never worked correctly.
51bbf5e
to
714c456
Compare
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.
LGTM, but I think we should also update the documentation to reflect that --no-foo
is no longer supported, right? The blurb from the docs:
You may also specify an arbitrary action by passing an Action subclass or other object that implements the same interface. The BooleanOptionalAction is available in argparse and adds support for boolean actions such as --foo and --no-foo:
It never was supported. Just now you will get an error instead of wrong result when you use BooleanOptionalAction in the way it was not supposed to be used. |
Right, but isn't the text I mentioned above suggesting that |
Read it in the context. The following example shows that it creates action for |
Yeah, I see the example. It just sort of reads a bit unclear to me and implies that I should be able to create a parser with: |
I do not see anything that implies that '--no-foo' works. And it never worked. |
Thank you for your review @savannahostrowski. |
They never worked correctly.