bpo-33109: argparse subparsers are once again not required by default by ned-deily · Pull Request #6919 · python/cpython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation7 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
bpo-26510 in 3.7.0a2 changed the behavior of argparse to make
subparsers required by default, returning to the behavior of 2.7
and 3.2. The behavior was changed in 3.3 to be no longer required.
While it might make more sense to have the default to required,
compatibility with 3.3 through 3.6 is probably less disruptive
than trying to reintroduce compatibility with 2.7 at this point.
This change restores the 3.6 behavior.
https://bugs.python.org/issue33109
bpo-26510 in 3.7.0a2 changed the behavior of argparse to make subparsers required by default, returning to the behavior of 2.7 and 3.2. The behavior was changed in 3.3 to be no longer required. While it might make more sense to have the default to required, compatibility with 3.3 through 3.6 is probably less disruptive than trying to reintroduce compatibility with 2.7 at this point. This change restores the 3.6 behavior.
I still think we should consider the new behaviour more correct and the 3.3-3.6 behaviour a bug. This reintroduces the bug.
@@ -1077,7 +1077,7 @@ def __init__(self, |
---|
prog, |
parser_class, |
dest=SUPPRESS, |
required=True, |
required=False, |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are here, please move required
to the end of the list of parameters. It was inserted in the middle of non-keyword-only parameters.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was discussed here
It makes no difference because add_subparsers
does not take positional arguments (all arguments are keyword-only). The ordering here was chosen to be consistent with the rest of the classes in the module
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. You are right.
Thanks @ned-deily for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
bpo-26510 in 3.7.0a2 changed the behavior of argparse to make subparsers required by default, returning to the behavior of 2.7 and 3.2. The behavior was changed in 3.3 to be no longer required. While it might make more sense to have the default to required, compatibility with 3.3 through 3.6 is probably less disruptive than trying to reintroduce compatibility with 2.7 at this point. This change restores the 3.6 behavior. (cherry picked from commit 8ebf5ce)
Co-authored-by: Ned Deily nad@python.org
ned-deily added a commit that referenced this pull request
bpo-26510 in 3.7.0a2 changed the behavior of argparse to make subparsers required by default, returning to the behavior of 2.7 and 3.2. The behavior was changed in 3.3 to be no longer required. While it might make more sense to have the default to required, compatibility with 3.3 through 3.6 is probably less disruptive than trying to reintroduce compatibility with 2.7 at this point. This change restores the 3.6 behavior. (cherry picked from commit 8ebf5ce)
Co-authored-by: Ned Deily nad@python.org
smcv mentioned this pull request