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 @@ -271,7 +271,12 @@ def add_argument(*args, **kwargs):
271271 # Note: We control all inputs.
272272 kwargs ["help" ] = kwargs ["help" ] % kwargs
273273 if not is_append :
274- kwargs ["default" ] = argparse .SUPPRESS
274+ # Workaround for jsonargparse bug #852: empty subcommands that have the exact same name
275+ # as a boolean option flag will cause a crash (NSKeyError) if the option's default
276+ # is set to argparse.SUPPRESS. We bypass this by providing a sentinel value. However,
277+ # we must still use argparse.SUPPRESS if the option has a 'type' validator, as
278+ # jsonargparse will throw a ValidationError for our custom sentinel object.
279+ kwargs ["default" ] = argparse .SUPPRESS if "type" in kwargs else self .default_sentinel
275280
276281 common_group .add_argument (* args , ** kwargs )
277282
You can’t perform that action at this time.
0 commit comments