From e15547a6857bb582e23e64d4be1ea7cdb5a3e2d9 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 4 Mar 2026 08:39:07 +0100 Subject: [PATCH] import ActionSubCommands from jsonargparse --- src/borg/archiver/completion_cmd.py | 8 ++++---- src/borg/helpers/argparsing.py | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/borg/archiver/completion_cmd.py b/src/borg/archiver/completion_cmd.py index 3e6aa4fd9..4b973fafc 100644 --- a/src/borg/archiver/completion_cmd.py +++ b/src/borg/archiver/completion_cmd.py @@ -66,7 +66,7 @@ from ..helpers import ( parse_file_size, ) from ..helpers.argparsing import ArgumentParser -from ..helpers.argparsing import _ActionSubCommands +from ..helpers.argparsing import ActionSubCommands from ..helpers.time import timestamp from ..helpers.parseformat import partial_format from ..manifest import AI_HUMAN_SORT_KEYS @@ -631,7 +631,7 @@ def _attach_completion(parser: ArgumentParser, type_class, completion_dict: dict """Tag all arguments with type `type_class` with completion choices from `completion_dict`.""" for action in parser._actions: - if isinstance(action, _ActionSubCommands): + if isinstance(action, ActionSubCommands): for sub in action.choices.values(): _attach_completion(sub, type_class, completion_dict) continue @@ -643,7 +643,7 @@ def _attach_completion(parser: ArgumentParser, type_class, completion_dict: dict def _attach_help_completion(parser: ArgumentParser, completion_dict: dict): """Tag the 'topic' argument of the 'help' command with static completion choices.""" for action in parser._actions: - if isinstance(action, _ActionSubCommands): + if isinstance(action, ActionSubCommands): for sub in action.choices.values(): _attach_help_completion(sub, completion_dict) continue @@ -690,7 +690,7 @@ class CompletionMixIn: # Collect all commands and help topics for "borg help" completion help_choices = list(self.helptext.keys()) for action in parser._actions: - if isinstance(action, _ActionSubCommands): + if isinstance(action, ActionSubCommands): help_choices.extend(action.choices.keys()) help_completion_fn = "_borg_help_topics" diff --git a/src/borg/helpers/argparsing.py b/src/borg/helpers/argparsing.py index f16809022..9a073705b 100644 --- a/src/borg/helpers/argparsing.py +++ b/src/borg/helpers/argparsing.py @@ -100,12 +100,8 @@ from typing import Any # all other imports of these names import them from here: from argparse import Action, ArgumentError, ArgumentTypeError, RawDescriptionHelpFormatter # noqa: F401 from jsonargparse import ArgumentParser as _ArgumentParser # we subclass that to add custom behavior -from jsonargparse import Namespace, SUPPRESS, REMAINDER # noqa: F401 -from jsonargparse.typing import register_type # noqa: F401 -from jsonargparse.typing import PositiveInt # noqa: F401 - -# borg completion uses these private symbols, so we need to import them: -from jsonargparse._actions import _ActionSubCommands # noqa: F401 +from jsonargparse import Namespace, ActionSubCommands, SUPPRESS, REMAINDER # noqa: F401 +from jsonargparse.typing import register_type, PositiveInt # noqa: F401 class ArgumentParser(_ArgumentParser):