You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ArgumentParser.parse_args exits on missing required argument with exit_on_error=False #90598
When calling ArgumentParser.parse_args(list_of_things_to_parse) sys.exit gets called even though the parser was constructed with exit_on_error=False. It doesn't matter if the parser has any subparsers added or not.
The docs say
Normally, when you pass an invalid argument list to the parse_args()
method of an ArgumentParser, it will exit with error info.
If the user would like to catch errors manually, the feature can be
enabled by setting exit_on_error to False:
[example code follows]
The docs make me believe what I'm trying to do should work.
I've attached a minimal working example to show what happens (with and without subparsers).
Activity
trilader commentedon Jan 19, 2022
When calling ArgumentParser.parse_args(list_of_things_to_parse) sys.exit gets called even though the parser was constructed with exit_on_error=False. It doesn't matter if the parser has any subparsers added or not.
The docs say
The docs make me believe what I'm trying to do should work.
I've attached a minimal working example to show what happens (with and without subparsers).
paulj3 commentedon Feb 2, 2022
Duplicate of https://bugs.python.org/issue41255
Argparse.parse_args exits on unrecognized option with exit_on_error=False