Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-33109: argparse subparsers are once again not required by default#6919

Merged
ned-deily merged 1 commit into
python:masterpython/cpython:masterfrom
ned-deily:bpo-33109ned-deily/cpython:bpo-33109Copy head branch name to clipboard
May 24, 2018
Merged

bpo-33109: argparse subparsers are once again not required by default#6919
ned-deily merged 1 commit into
python:masterpython/cpython:masterfrom
ned-deily:bpo-33109ned-deily/cpython:bpo-33109Copy head branch name to clipboard

Conversation

@ned-deily

@ned-deily ned-deily commented May 16, 2018

Copy link
Copy Markdown
Member

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.
@asottile

Copy link
Copy Markdown
Contributor

I still think we should consider the new behaviour more correct and the 3.3-3.6 behaviour a bug. This reintroduces the bug.

@ned-deily

Copy link
Copy Markdown
Member Author

@asottile Understood but see the discussion in https://bugs.python.org/issue33109 as to why we agree that compatibility with 3.6 is more important. Counterarguments welcome there!

Comment thread Lib/argparse.py
parser_class,
dest=SUPPRESS,
required=True,
required=False,

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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.

@ned-deily ned-deily merged commit 8ebf5ce into python:master May 24, 2018
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @ned-deily for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@ned-deily ned-deily deleted the bpo-33109 branch May 24, 2018 01:55
@bedevere-bot

Copy link
Copy Markdown

GH-7089 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 24, 2018
…pythonGH-6919)

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 May 24, 2018
…GH-6919) (GH-7089)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.