diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-03-10 08:29:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 08:29:14 +0100 |
commit | f93b9b5af928e127635cc0f2976da5be22d6c735 (patch) | |
tree | 9b5d08c0d85bd177ce94ffec7c2a2fef8d22ea45 /gitlab/v4/cli.py | |
parent | de73ea7933d3f3c94aa27a7d9b9ea7bfd64ad1f1 (diff) | |
parent | 8224b4066e84720d7efed3b7891c47af73cc57ca (diff) | |
download | gitlab-f93b9b5af928e127635cc0f2976da5be22d6c735.tar.gz |
Merge pull request #1367 from JohnVillalovos/jlvillal/from_parent_attrs
fix: checking if RESTManager._from_parent_attrs is set
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r-- | gitlab/v4/cli.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index a768999..c01f06b 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -69,7 +69,7 @@ class GitlabCLI(object): # Get the object (lazy), then act if in_obj: data = {} - if hasattr(self.mgr, "_from_parent_attrs"): + if self.mgr._from_parent_attrs: for k in self.mgr._from_parent_attrs: data[k] = self.args[k] if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.cls): @@ -138,13 +138,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): sub_parser_action = sub_parser.add_parser(action_name) sub_parser_action.add_argument("--sudo", required=False) - if hasattr(mgr_cls, "_from_parent_attrs"): - [ + if mgr_cls._from_parent_attrs: + for x in mgr_cls._from_parent_attrs: sub_parser_action.add_argument( "--%s" % x.replace("_", "-"), required=True ) - for x in mgr_cls._from_parent_attrs - ] if action_name == "list": if hasattr(mgr_cls, "_list_filters"): @@ -221,13 +219,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): for action_name in cli.custom_actions[name]: sub_parser_action = sub_parser.add_parser(action_name) # Get the attributes for URL/path construction - if hasattr(mgr_cls, "_from_parent_attrs"): - [ + if mgr_cls._from_parent_attrs: + for x in mgr_cls._from_parent_attrs: sub_parser_action.add_argument( "--%s" % x.replace("_", "-"), required=True ) - for x in mgr_cls._from_parent_attrs - ] sub_parser_action.add_argument("--sudo", required=False) # We need to get the object somehow @@ -256,13 +252,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): name = mgr_cls.__name__ for action_name in cli.custom_actions[name]: sub_parser_action = sub_parser.add_parser(action_name) - if hasattr(mgr_cls, "_from_parent_attrs"): - [ + if mgr_cls._from_parent_attrs: + for x in mgr_cls._from_parent_attrs: sub_parser_action.add_argument( "--%s" % x.replace("_", "-"), required=True ) - for x in mgr_cls._from_parent_attrs - ] sub_parser_action.add_argument("--sudo", required=False) required, optional, dummy = cli.custom_actions[name][action_name] |