-
Notifications
You must be signed in to change notification settings - Fork 241
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
Make paasta without args compat with py3 #1428
Conversation
The usual fix for this is |
Second attempt with required=true |
paasta_tools/cli/cli.py
Outdated
@@ -84,6 +84,10 @@ def get_argparser(): | |||
) | |||
|
|||
subparsers = parser.add_subparsers(help="[-h, --help] for subcommand help") | |||
subparsers.required = True | |||
# https://stackoverflow.com/questions/18282403/argparse-with-required-subcommands/18283730#18283730 | |||
subparsers.dest = 'command' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a keyword to add_subparsers
(but .required
cannot for some reason, maybe I'll make a PR to stdlib to enable this). Here's an example from pre-commit (note that pre-commit avoids needing .required = true
due to some other hax that I wouldn't suggest (it implements a "default" command))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True to my word, here's the cpython PR: python/cpython#3027
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Till we upgrade to a version of python with that PR, then I should ship what I have as is, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move dest='command'
as a kwarg to add_subparsers
, but you won't be able to move .required = ...
until then.
No description provided.