Title: [argparse] Add required argument to add_subparsers
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, bethard, memeplex, paul.j3
Priority: normal Keywords:

Created on 2016-03-08 13:56 by memeplex, last changed 2017-08-15 03:23 by Anthony Sottile.

Pull Requests
URL Status Linked Edit
PR 3027 open Anthony Sottile, 2017-08-08 18:02
Messages (3)
msg261358 - (view) Author: Memeplex (memeplex) Date: 2016-03-08 13:56
It's useful in combination with dest. Currently you have to set required as an attribute. This is not only inconsistent but not even documented as a valid usage (in general, it's not clear from the docs whether attribute setting -vs argument passing- is a valid usage).
msg261535 - (view) Author: paul j3 (paul.j3) * Date: 2016-03-11 00:01
This has been raised before.  I think

is the correct issue.

It used to be that 'subparsers' were required.  But there was a change in how 'required' arguments were tested, and 'subparsers' fell through the cracks.  Now subparsers are optional (at least the parser doesn't raise an error).  The temporary fix is to set the 'required' attribute after creation.

I proposed that the default be 'required=True', and that we be allowed to set the parameter.  But that patch, like many others, has languished.
msg300282 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2017-08-15 03:23
I've added a patch for this

Would love to get a review so it could be included
Date User Action Args
2017-08-15 03:23:46Anthony Sottilesetnosy: + Anthony Sottile
messages: + msg300282
2017-08-08 18:02:02Anthony Sottilesetpull_requests: + pull_request3061
2016-03-11 00:01:03paul.j3setnosy: + paul.j3
messages: + msg261535
2016-03-08 13:58:22memeplexsetnosy: + bethard
2016-03-08 13:56:53memeplexsettitle: Add required argument to add_subparsers -> [argparse] Add required argument to add_subparsers
2016-03-08 13:56:01memeplexcreate