-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-58573: Fix conflicts between abbreviated long options in the parent parser and subparsers in argparse #124631
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
Merged
serhiy-storchaka
merged 2 commits into
python:main
from
serhiy-storchaka:argparse-abbrev-subparser
Sep 29, 2024
Merged
gh-58573: Fix conflicts between abbreviated long options in the parent parser and subparsers in argparse #124631
serhiy-storchaka
merged 2 commits into
python:main
from
serhiy-storchaka:argparse-abbrev-subparser
Sep 29, 2024
+52
−34
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
… parent parser and subparsers in argparse Check for ambiguous options if the option is consumed, not when it is parsed.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, @serhiy-storchaka, I could not cleanly backport this to
|
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 29, 2024
… parent parser and subparsers in argparse (pythonGH-124631) Check for ambiguous options if the option is consumed, not when it is parsed. (cherry picked from commit 3f27153) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-124759 is a backport of this pull request to the 3.12 branch. |
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Sep 29, 2024
… in the parent parser and subparsers in argparse (pythonGH-124631) Check for ambiguous options if the option is consumed, not when it is parsed. (cherry picked from commit 3f27153) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-124760 is a backport of this pull request to the 3.13 branch. |
AdamWill
added a commit
to AdamWill/pykickstart
that referenced
this pull request
Oct 2, 2024
In Python 3.13 and 3.12.7, the behavior of _parse_optional has changed. It used to raise an error on multiple matching actions itself, and only ever return None or an option tuple. Now the "raise error on multiple matching actions" code was moved out into consume_optional, and _parse_optional returns either None or a *list* of option tuples, which contains more than one if multiple actions match. See: python/cpython#124631 python/cpython#58573 This adapts to the change in a way that should work on both older and newer Pythons. I re-implemented the handling of multiple matching options so we don't have to worry about licensing and attribution if we copied in upstream's version. Signed-off-by: Adam Williamson <awilliam@redhat.com>
AdamWill
added a commit
to AdamWill/pykickstart
that referenced
this pull request
Oct 2, 2024
In Python 3.13 and 3.12.7, the behavior of _parse_optional has changed. It used to raise an error on multiple matching actions itself, and only ever return None or an option tuple. Now the "raise error on multiple matching actions" code was moved out into consume_optional, and _parse_optional returns either None or a *list* of option tuples, which contains more than one if multiple actions match. See: python/cpython#124631 python/cpython#58573 This adapts to the change in a way that should work on both older and newer Pythons. Signed-off-by: Adam Williamson <awilliam@redhat.com>
AdamWill
added a commit
to AdamWill/pykickstart
that referenced
this pull request
Oct 2, 2024
In Python 3.13 and 3.12.7, the behavior of _parse_optional has changed. It used to raise an error on multiple matching actions itself, and only ever return None or an option tuple. Now the "raise error on multiple matching actions" code was moved out into consume_optional, and _parse_optional returns either None or a *list* of option tuples, which contains more than one if multiple actions match. See: python/cpython#124631 python/cpython#58573 This adapts to the change in a way that should work on both older and newer Pythons. Signed-off-by: Adam Williamson <awilliam@redhat.com>
bcl
pushed a commit
to pykickstart/pykickstart
that referenced
this pull request
Oct 2, 2024
In Python 3.13 and 3.12.7, the behavior of _parse_optional has changed. It used to raise an error on multiple matching actions itself, and only ever return None or an option tuple. Now the "raise error on multiple matching actions" code was moved out into consume_optional, and _parse_optional returns either None or a *list* of option tuples, which contains more than one if multiple actions match. See: python/cpython#124631 python/cpython#58573 This adapts to the change in a way that should work on both older and newer Pythons. Signed-off-by: Adam Williamson <awilliam@redhat.com>
bcl
pushed a commit
to bcl/pykickstart
that referenced
this pull request
Oct 4, 2024
In Python 3.13 and 3.12.7, the behavior of _parse_optional has changed. It used to raise an error on multiple matching actions itself, and only ever return None or an option tuple. Now the "raise error on multiple matching actions" code was moved out into consume_optional, and _parse_optional returns either None or a *list* of option tuples, which contains more than one if multiple actions match. See: python/cpython#124631 python/cpython#58573 This adapts to the change in a way that should work on both older and newer Pythons. NOTE: This includes the fix for the typo that is in a separate commit on master. Signed-off-by: Adam Williamson <awilliam@redhat.com> Signed-off-by: Brian C. Lane <bcl@redhat.com> Resolves: RHEL-61426
This was referenced Oct 5, 2024
serhiy-storchaka
added a commit
that referenced
this pull request
Oct 7, 2024
This was referenced Nov 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check for ambiguous options if the option is consumed, not when it is parsed.