[issue33109] argparse: make new 'required' argument to add_subparsers default to False instead of True

Brian Skinn report at bugs.python.org
Mon May 7 12:05:19 EDT 2018


Brian Skinn <bskinn at alum.mit.edu> added the comment:

I second Wolfgang's recommendation to change the default back to `False`.

I started developing CLI apps &c. in Python ~4yrs ago; I dabbled briefly in 2.7, then switched firmly to Python 3.  When I started, I was aimed at supporting 3.3 to 3.5; now I'm specifically supporting 3.4 to 3.6, but starting to test my code against the 3.7b versions.

Thus, all I've ever known is the default `required=False` behavior. On my one tool currently using subparsers (https://github.com/bskinn/sphobjinv), I made the subparser choice optional, to allow a `sphobjinv --version` invocation. So, when 3.7 failed that test (https://github.com/bskinn/sphobjinv/blob/6c1f22e40dc3d129485462aec05adbed2ff40ab8/sphobjinv/test/sphobjinv_cli.py#L419-L422), it seemed like a regression to me.

All that said, given that the `subparsers.required = False` fix is a clean, single line, I have no beef with a `True` default if that's preferred. However, please include this change in the 3.7 CHANGELOG, at least.

----------
nosy: +bskinn

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33109>
_______________________________________


More information about the Python-bugs-list mailing list