Skip to content

Commit 21f5116

Browse files
1 parent 93be9c0 commit 21f5116

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/borg/archiver/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)