File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,12 @@ def add_argument(*args, **kwargs):
270270 # Note: We control all inputs.
271271 kwargs ["help" ] = kwargs ["help" ] % kwargs
272272 if not is_append :
273- kwargs ["default" ] = argparse .SUPPRESS
273+ # Workaround for jsonargparse bug #852: empty subcommands that have the exact same name
274+ # as a boolean option flag will cause a crash (NSKeyError) if the option's default
275+ # is set to argparse.SUPPRESS. We bypass this by providing a sentinel value. However,
276+ # we must still use argparse.SUPPRESS if the option has a 'type' validator, as
277+ # jsonargparse will throw a ValidationError for our custom sentinel object.
278+ kwargs ["default" ] = argparse .SUPPRESS if "type" in kwargs else self .default_sentinel
274279
275280 common_group .add_argument (* args , ** kwargs )
276281
You can’t perform that action at this time.
0 commit comments