Message173691
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. |
|
Date |
User |
Action |
Args |
2012-10-24 15:06:53 | telmich | set | recipients:
+ telmich, bethard, r.david.murray |
2012-10-24 15:06:53 | telmich | set | messageid: <1351091213.61.0.930923697863.issue16308@psf.upfronthosting.co.za> |
2012-10-24 15:06:53 | telmich | link | issue16308 messages |
2012-10-24 15:06:53 | telmich | create | |
|