Skip to content

Commit 074aaa1

Browse files
1 parent 5331142 commit 074aaa1

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
@@ -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

0 commit comments

Comments
 (0)