From ee2ebb79b8e89dbe161f0ba87d950b2dfac8c82f Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 16 Jun 2023 10:57:01 -0700 Subject: [PATCH] Find sub-actions for an action without an isinstance() check. --- borgmatic/commands/completion/actions.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/borgmatic/commands/completion/actions.py b/borgmatic/commands/completion/actions.py index 903670d..690d0a8 100644 --- a/borgmatic/commands/completion/actions.py +++ b/borgmatic/commands/completion/actions.py @@ -1,6 +1,3 @@ -import argparse - - def upgrade_message(language: str, upgrade_command: str, completion_file: str): return f''' Your {language} completions script is from a different version of borgmatic than is @@ -25,11 +22,11 @@ def available_actions(subparsers, current_action=None): actions_to_subactions = { action: tuple( subaction_name - for subaction in subparser._actions - if isinstance(subaction, argparse._SubParsersAction) - for subaction_name in subaction.choices.keys() + for group_action in subparser._subparsers._group_actions + for subaction_name in group_action.choices.keys() ) for action, subparser in subparsers.choices.items() + if subparser._subparsers } current_subactions = actions_to_subactions.get(current_action)