This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients paul.j3, zachrahan
Date 2017-01-20.05:38:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484890734.49.0.690486182916.issue29298@psf.upfronthosting.co.za>
In-reply-to
Content
http://bugs.python.org/issue9253  argparse: optional subparsers

Initially this bug/issue was a request to allow subparsers to be optional.  But with the change in how required actions are handled, subparsers are now optional by default.

As you learned from the SO question you now have to specify

subparsers.required = True

This is also discussed in my post (and following ones)

http://bugs.python.org/issue9253#msg186387

The default 'dest' is SUPPRESS.  The error you report occurs because the 'required' error mechanism cannot handle that value. The suggest fix is to assign `dest`, even if it is not needed in the Namespace.  For now it is needed for error reporting.

Reviewing my suggested patches, it looks like I generate a 'dest' substitute from the subparser names.  So the 'required' error would look like

python: error: the following arguments are required: {cmd1, cmd2}

I think this issue can be closed with a reference to 9253. Or maybe that issue is too old, long and confusing, and we need a new bug/issue.
History
Date User Action Args
2017-01-20 05:38:54paul.j3setrecipients: + paul.j3, zachrahan
2017-01-20 05:38:54paul.j3setmessageid: <1484890734.49.0.690486182916.issue29298@psf.upfronthosting.co.za>
2017-01-20 05:38:54paul.j3linkissue29298 messages
2017-01-20 05:38:53paul.j3create