@@ -604,13 +604,11 @@ subparser names, the feature can be enabled by setting ``suggest_on_error`` to
604604``True ``. Note that this only applies for arguments when the choices specified
605605are strings::
606606
607- >>> parser = argparse.ArgumentParser(description='Process some integers.',
608- suggest_on_error=True)
609- >>> parser.add_argument('--action', choices=['sum', 'max'])
610- >>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
611- ... help='an integer for the accumulator')
612- >>> parser.parse_args(['--action', 'sumn', 1, 2, 3])
613- tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant 'sum'? (choose from 'sum', 'max')
607+ >>> parser = argparse.ArgumentParser(suggest_on_error=True)
608+ >>> parser.add_argument('--action', choices=['debug', 'dryrun'])
609+ >>> parser.parse_args(['--action', 'debugg'])
610+ usage: tester.py [-h] [--action {debug,dryrun}]
611+ tester.py: error: argument --action: invalid choice: 'debugg', maybe you meant 'debug'? (choose from debug, dryrun)
614612
615613If you're writing code that needs to be compatible with older Python versions
616614and want to opportunistically use ``suggest_on_error `` when it's available, you
0 commit comments