Open
Description
When adding an argument with argparse.ArgumentParser.add_argument
, it is tempting to pass type=bool
to create an option that is specified without a value, such as --enable-foo
. This doesn't work, and in fact creates a subtle bug: --enable-foo
silently swallows the next argument, so a command like python3 program.py --enable-foo x y z
will work but only leave y
and z
to be used as other arguments. https://stackoverflow.com/a/15008806
To prevent this, I think the best we can do is to add an overload that returns NoReturn
when you pass in type=bool
.