Closed as not planned
Description
Bug report
Bug description:
When we have sub_parser argument which is substring of main parser, getting error as ambiguous option
python sample.py show -foo "data"
usage: PROG [-h] [-foobar FOOBAR] [-foobar1 FOOBAR1] {show} ...
PROG: error: ambiguous option: -foo could match -foobar, -foobar1
Observing with python 3.11.3. Earlier it works fine with python 3.5
# Add a code block here, if required
parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)
parser.add_argument('-foobar', action='store')
parser.add_argument('-foobar1', action='store')
sub_parser = parser.add_subparsers(dest='command')
# Show
sub_parser_show = sub_parser.add_parser('show', help='Print Client ID for a specific environment',
description= 'Print Client ID for a specific environment')
sub_parser_show.add_argument('-foo', dest = 'env_name', action='store',
help='Environment name Eg: "development"')
args = parser.parse_args()
print (args)
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Doc issues