Repository navigation
[argparse] Add required argument to add_subparsers #70697
Description
Activity
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).
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
on Mar 8, 2016 - changed the title
[-]Add required argument to add_subparsers[/-][+][argparse] Add required argument to add_subparsers[/+]on Mar 8, 2016 This has been raised before. I think
http://bugs.python.org/issue9253
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.
I've added a patch for this #3027
Would love to get a review so it could be included
requiredkwarg. #3027Note: 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: