From 80873777c6d6642d2871f5584eb70a9adfc8ed42 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 23 Dec 2022 22:34:49 +0100 Subject: [PATCH] Code simplification/explicitation --- moulinette/interfaces/cli.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index 5cbd2dc8..efb37aba 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -288,14 +288,12 @@ class ActionsMapParser(BaseActionsMapParser): """ - def __init__( - self, parent=None, parser=None, subparser_kwargs=None, top_parser=None, **kwargs - ): + def __init__(self, parent=None, parser=None, subparser_kwargs=None, top_parser=None): + super(ActionsMapParser, self).__init__(parent) if subparser_kwargs is None: subparser_kwargs = {"title": "categories", "required": False} - self._parser = parser or ExtendedArgumentParser() self._subparsers = self._parser.add_subparsers(**subparser_kwargs) self.global_parser = parent.global_parser if parent else None @@ -336,7 +334,7 @@ class ActionsMapParser(BaseActionsMapParser): parser = self._subparsers.add_parser( name, description=category_help, help=category_help, **kwargs ) - return self.__class__(self, parser, {"title": "subcommands", "required": True}) + return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "subcommands", "required": True}) def add_subcategory_parser(self, name, subcategory_help=None, **kwargs): """Add a parser for a subcategory @@ -355,7 +353,7 @@ class ActionsMapParser(BaseActionsMapParser): help=subcategory_help, **kwargs, ) - return self.__class__(self, parser, {"title": "actions", "required": True}) + return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "actions", "required": True}) def add_action_parser( self,