This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients remi.lapeyre
Date 2020-06-04.11:59:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
The action is used to store None, True or False when an argument like --foo or --no-foo is given to the cli so it has no used for this action, but it is accepted without warning:

Python 3.10.0a0 (heads/bpo-wip:6e23a9c82b, Jun  4 2020, 13:41:35) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo', const='this_is_not_used', action=argparse.BooleanOptionalAction)
BooleanOptionalAction(option_strings=['--foo', '--no-foo'], dest='foo', nargs=0, const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> args = parser.parse_args()
>>> args
Namespace(foo=None)



We could either always refuse this argument, or accepted and raise ValueError if it is different than None. The attached PR does the first.
History
Date User Action Args
2020-06-04 11:59:48remi.lapeyresetrecipients: + remi.lapeyre
2020-06-04 11:59:48remi.lapeyresetmessageid: <[email protected]>
2020-06-04 11:59:48remi.lapeyrelinkissue40862 messages
2020-06-04 11:59:48remi.lapeyrecreate