-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
For argparse add_argument with action='store_const', const should default to None. #82061
Comments
Currently, when >>> from argparse import ArgumentParser
>>> parser = ArgumentParser()
>>> parser.add_argument("--foo", help="foo", action='store_const')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/captain/projects/cpython/Lib/argparse.py", line 1350, in add_argument
action = action_class(**kwargs)
TypeError: __init__() missing 1 required positional argument: 'const'
>>> Specifying the >>> parser.add_argument("--foo", help="foo", action='store_const', const=None)
_StoreConstAction(option_strings=['--foo'], dest='foo', nargs=0, const=None, default=None, type=None, choices=None, help='foo', metavar=None) Originally the docs, said when After this commit : https://github.com/python/cpython/commi/b4912b8ed367e540ee060fe912f841cc764fd293, The docs were updated to match the implementation to fix Bpo issues : https://bugs.python.org/issue25299 https://bugs.python.org/issue24754 and https://bugs.python.org/issue25314 I suggest that we make |
Sounds reasonable to me. |
Hi Joannah, I'm a new contributor and happy to take a crack at this if you haven't already started on a fix / would like me to do that. Thanks! |
@jack__d, please feel free to work on a PR. Also, do not hesitate to ask any questions along the way. Thanks for contributing to CPython. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: