-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
argparse.ArgumentParser does not raise on duplicated subparsers, even though it does on duplicated flags #83897
Comments
If one tries to add twice the same flag to an ArgumentParser, one gets a helpful exception: from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument("--foo")
p.add_argument("--foo") results in
However, adding twice the same subparser raises no exception: from argparse import ArgumentParser
p = ArgumentParser()
sp = p.add_subparsers()
sp.add_parser("foo")
sp.add_parser("foo") even though the two subparsers shadow one another in the same way as two identical flags. |
Would you like to work-up a patch to fix this? |
Sure, #18605 it is. |
In 3.11 a bug with duplicated names/aliases of subparsers was fixed in python/cpython#83897. This leads to an argument error being raised whenever a duplicate is found. In previous python versions additional parsers were just overridden without a warning.
Please note that this issue is labeled as |
@ppolewicz PRs are nearly always merged into main and only sometimes backported. Tracker version labels indicate the version(s) reported for, not necessarily the versions patched. Since we moved the repository to github, PR titles indicate the version(s) actually patched (with 'main' the default). The tracker move to github messed up merge reporting for old PRs. I repointed the PR for this issue to the gh number so it is listed immediately above. |
This was actually a duplicate of #59061. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: