-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
[argparse] Add required argument to add_subparsers #70697
Comments
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). |
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 |
required
kwarg. #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:
The text was updated successfully, but these errors were encountered: