[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-07-31 Thread Vinay Sajip


Change by Vinay Sajip :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-07-31 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 0ad173249d287794d53e6a1fe2d58bb2adee2276 by Jack DeVries in 
branch 'main':
bpo-37880: for argparse add_argument with action='store_const', const now 
defaults to None. (GH-26707)
https://github.com/python/cpython/commit/0ad173249d287794d53e6a1fe2d58bb2adee2276


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-06-14 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> vinay.sajip
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-06-13 Thread Jack DeVries


Change by Jack DeVries :


--
keywords: +patch
pull_requests: +25294
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26707

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-06-12 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

@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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-06-12 Thread Jack DeVries


Jack DeVries  added the comment:

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!

--
nosy: +jack__d

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2021-06-12 Thread Jacob Walls


Jacob Walls  added the comment:

Sounds reasonable to me.

--
components: +Library (Lib)
nosy: +jacobtylerwalls
type:  -> behavior
versions: +Python 3.11 -Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2019-08-17 Thread Joannah Nanjekye


New submission from Joannah Nanjekye :

Currently, when `parser.add_argument()` is given argument with 
`action='store_const'` and no `const` argument , it throws an exception :

>>> from argparse import ArgumentParser
>>> parser = ArgumentParser()
>>> parser.add_argument("--foo", help="foo", action='store_const')
Traceback (most recent call last):
File "", line 1, in 
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 `const` argument stops this exception:

>>> 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 `action` was set to` 'store_const'` `const` 
defaulted to `None` which was not matching with the implementation at the time. 

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 `const` default to `None` If `action='store_const'` as 
was intended originally before edits to the docs. If no one objects, I can open 
a PR for this.

--
messages: 349911
nosy: A. Skrobov, nanjekyejoannah, r.david.murray
priority: normal
severity: normal
status: open
title: For argparse add_argument with action='store_const', const should 
default to None.
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com