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 telmich
Recipients bethard, r.david.murray, telmich
Date 2012-10-24.15:06:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351091213.61.0.930923697863.issue16308@psf.upfronthosting.co.za>
In-reply-to
Content
Interesting! The issue 9523 has now somehow become obsolete,
as in 3.3.0 subcommands are de-facto optional, which is the problem I am facing.

Regarding my last comment, here are the relations:

- add a parameter to add_subparsers(): required
  This is a similar proposal to the original issue 9523, though the other way round: in #9523 the required case was proposed to be the default. As 3.3.0 now defaults to optional, my proposal was to keep this behaviour and allow passing required=True.

- Change implementation in such a way that using parser.set_defaults() on the main parser does not affect the sub parsers:
   As set_defaults() already exists, I think this is the cleaner method to implement this feature instead of using the default='' variant specified in #9523.

   Besides that I think the current behaviour of set_defaults changing the functions of the sub parsers is definitely a bug on its own.

So summarised / compared:

- Python 3.3.0 seems to treat subcommands as optional, compared to the original issue 9523

- set_defaults(func=x) on the main parsers affects sub parsers, which renders using set_defaults() useless

- If requiring the behaviour of set_defaults() to pass the func= arguments to other parsers, the parents=[] argument already exists

- To fix this issue, only correcting the set_defaults() call would be necessary

- It makes sense though, to add the 'required' parameter, as the need has also been spotted by others already.
History
Date User Action Args
2012-10-24 15:06:53telmichsetrecipients: + telmich, bethard, r.david.murray
2012-10-24 15:06:53telmichsetmessageid: <1351091213.61.0.930923697863.issue16308@psf.upfronthosting.co.za>
2012-10-24 15:06:53telmichlinkissue16308 messages
2012-10-24 15:06:53telmichcreate