From 0a6d8071e1dbd9781fd6d1a07437507a991a15a1 Mon Sep 17 00:00:00 2001 From: Frantisek Tobias Date: Fri, 15 Nov 2024 13:12:33 +0100 Subject: [PATCH] kresctl: command: completion: remove redundant code --- python/knot_resolver/client/command.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/python/knot_resolver/client/command.py b/python/knot_resolver/client/command.py index dbd99227a..33f2c2ad9 100644 --- a/python/knot_resolver/client/command.py +++ b/python/knot_resolver/client/command.py @@ -152,20 +152,12 @@ def completion(parser: argparse.ArgumentParser, args: Optional[List[str]] = None curr_index += 1 if subpar: cmd = get_subparser_command(subpar) - if cmd is not None: - if len(args) > curr_index: - words = cmd.completion(subpar, args, curr_index) + if cmd is None: + return get_subparsers_words(subpar._actions) # pylint: disable=protected-access - return words + if len(args) > curr_index: + return cmd.completion(subpar, args, curr_index) - subpar_actions = subpar._actions # pylint: disable=protected-access - subparser_words = get_subparsers_words(subpar_actions) - words = {} - for action in subpar_actions: - if action.dest not in subparser_words: - subparser_words[action.dest] = action.help or None - - words.update(subparser_words) return words elif uarg in ["-s", "--socket", "-c", "--config"]: