GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — bpo-26510: Allow argparse add_subparsers to take `required` kwarg. by asottile · Pull Request #3027 · python/cpython Conversation
|
|
Actually on second thought, I'm going to try and restore the python 2 behaviour -- optional subparsers rarely make sense (and it'll will make writing py2 + py3 simpler). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed that required=True is the better default.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please update docs and news.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For maximum backward compatibility, the new parameter should be added to the end.
(I don’t personnally write calls like something('abc', SUPPRESS, True, None, None) but they are supported, and should not be broken when possible.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
add_subparsers itself takes no keyword arguments so I don't think there's a concern of the private api here.
>>> parser.add_subparsers('foo', True, False) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: add_subparsers() takes 1 positional argument but 4 were given
(the 1 positional argument here being self)
The ordering I chose was intentional to match the signatures in the rest of the file.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@merwok do I monty-python it up now? I'm unclear on the process for dismissing a review :P
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The review holding this up is «please update docs and news» :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
whoops totally missed that! I'll get right on it :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Nobody expects the Spanish Inquisition! @merwok: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This looks all right! Just to be exhaustive, are the interactions ok with required options and required subparses? (e.g. error messages mention both the missing required option and the missing required subparser) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Patch by <contributor> should end with a period. :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I attempted to follow this example -- if not perhaps that should be updated.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help Mariatta and for the link Anthony!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I can check these, though they'd already be broken (not a regression) -- I'm not actually introducing any new functionality, just a new default. let me go through the scenarios though! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I fixed the only crash I could find related to this: 6e61d8a It was already triggerable with the following: import argparse parser = argparse.ArgumentParser() parsers = parser.add_subparsers() parsers.required = True parsers.add_parser('foo') parsers.add_parser('bar') parser.parse_args() The regression test I added alongside failed in the same way before patching (yay TDD). Should this get called out separately? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Agreed, this looks like an unrelated problem that needs its own bug and PRs. Good catch! My question was more related to the interaction of a required subparser with a required option, but I guess if there is any issue it was already in 2.7 and previous versions. I’m ready to approve this when you back out the latest commit. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This fixes a regression introduced between python2 and python3.
In Python 2 subparser commands are required. From Python 3.3 on they are optional. This is considered a bug and will be reversed in Python 3.7. For details see issues: * 16308: https://bugs.python.org/issue16308 * 9235: https://bugs.python.org/issue9253 and pull request: * 3027: python/cpython#3027
|
Encourage those that were CC'd on this to weigh in on #6919 and https://bugs.python.org/issue33109 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What version of Python was this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
3.7.0a2 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The default was changed in #6919 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-16588) The `required` argument to `argparse.add_subparsers` was added in #3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok
…honGH-16588) The `required` argument to `argparse.add_subparsers` was added in pythonGH-3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok (cherry picked from commit 9e71917) Co-authored-by: Adam J. Stewart <[email protected]>
…honGH-16588) The `required` argument to `argparse.add_subparsers` was added in pythonGH-3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok (cherry picked from commit 9e71917) Co-authored-by: Adam J. Stewart <[email protected]>
…16588) The `required` argument to `argparse.add_subparsers` was added in GH-3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok (cherry picked from commit 9e71917) Co-authored-by: Adam J. Stewart <[email protected]>
…16588) The `required` argument to `argparse.add_subparsers` was added in GH-3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok (cherry picked from commit 9e71917) Co-authored-by: Adam J. Stewart <[email protected]>
…honGH-16588) The `required` argument to `argparse.add_subparsers` was added in pythonGH-3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok (cherry picked from commit 9e71917) Co-authored-by: Adam J. Stewart <[email protected]>
…thonGH-16588) The `required` argument to `argparse.add_subparsers` was added in python#3027. This PR specifies the earliest version of Python where it is available. https://bugs.python.org/issue26510 Automerge-Triggered-By: @merwok
The required option was added in python 3.7.0a2 as a way to make subparsers required again (the default behaviour in Python 2.7). * https://bugs.python.org/issue9253 * python/cpython#3027 Since npm argparse 2.0.1 is a straight conversion of the Python 3.9.0rc1 version of argparse the required flag is valid here too.
… by @tsondergaard The required option was added in python 3.7.0a2 as a way to make subparsers required again (the default behaviour in Python 2.7). * https://bugs.python.org/issue9253 * python/cpython#3027 Since npm argparse 2.0.1 is a straight conversion of the Python 3.9.0rc1 version of argparse the required flag is valid here too.
…axy_jwd.py script See here: python/cpython#3027
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.