Closed as not planned
Description
Bug report
The following does not trigger an exception in ArgumentParser
, where I would expect an exception since the default value for --choice
is not in the list of choices:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--choice', choices=['a', 'b', 'c'], default='foo')
args = parser.parse_args() # args.choice == 'foo'
This is at least inconsistent behaviour, the following piece of code does trigger an exception for an invalid default value:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--num', type=int, default='foo')
args = parser.parse_args(args=[])
Environment: Python 3.10.9, Arch Linux, x86_64.
Metadata
Metadata
Assignees
Projects
Status
Doc issues