-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-26967: fix flag grouping with allow_abbrev=False #14316
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
Conversation
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b`. Checking for a leading `--` fixes this.
/cc @bethard |
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.
LGTM. Thanks a lot for providing the tests. They are very useful. :)
Thank you for taking care of the issue. |
@@ -182,6 +182,10 @@ ArgumentParser objects | |||
.. versionchanged:: 3.5 | |||
*allow_abbrev* parameter was added. | |||
|
|||
.. versionchanged:: 3.8 |
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.
.. versionchanged:: 3.8 | |
.. versionchanged:: 3.9 |
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.
I'm still hoping that this will be merged into the 3.8 branch before 3.8.0, but I guess we can adjust the number later.
I talked to a more experienced core dev, and we agreed that this a bugfix appropriate for 3.8. |
No worries! I'm just glad I can make a contribution, and getting it into 3.8 is even better 😄 |
Thanks @Zac-HD for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytestGH-5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967 (cherry picked from commit dffca9e) Co-authored-by: Zac Hatfield-Dodds <[email protected]>
GH-14759 is a backport of this pull request to the 3.8 branch. |
…4759) The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytestGH-5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967 (cherry picked from commit dffca9e) Co-authored-by: Zac Hatfield-Dodds <[email protected]>
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄 And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
The
allow_abbrev
option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing.However, the initial implementation also broke parsing of grouped short flags, such as
-ab
meaning-a -b
(or-a=b
). Checking the argument for a leading--
before rejecting it fixes this.This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great 😄
And this is my first PR to CPython, so please let me know if I've missed anything!
https://bugs.python.org/issue26967