Skip to content

Commit 5b81d7d

Browse files
authored
Merge pull request #1412 from JohnVillalovos/jlvillal/optional_get_attrs
chore: make Get.*Mixin._optional_get_attrs always present
2 parents 37af229 + 3c1a0b3 commit 5b81d7d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

gitlab/mixins.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class GetMixin(_RestManagerBase):
7575
_computed_path: Optional[str]
7676
_from_parent_attrs: Dict[str, Any]
7777
_obj_cls: Optional[Type[base.RESTObject]]
78+
_optional_get_attrs: Tuple[str, ...] = ()
7879
_parent: Optional[base.RESTObject]
7980
_parent_attrs: Dict[str, Any]
8081
_path: Optional[str]
@@ -119,6 +120,7 @@ class GetWithoutIdMixin(_RestManagerBase):
119120
_computed_path: Optional[str]
120121
_from_parent_attrs: Dict[str, Any]
121122
_obj_cls: Optional[Type[base.RESTObject]]
123+
_optional_get_attrs: Tuple[str, ...] = ()
122124
_parent: Optional[base.RESTObject]
123125
_parent_attrs: Dict[str, Any]
124126
_path: Optional[str]

gitlab/v4/cli.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,10 @@ def _populate_sub_parser_by_class(cls, sub_parser):
165165
id_attr = cls._id_attr.replace("_", "-")
166166
sub_parser_action.add_argument("--%s" % id_attr, required=True)
167167

168-
if hasattr(mgr_cls, "_optional_get_attrs"):
169-
[
170-
sub_parser_action.add_argument(
171-
"--%s" % x.replace("_", "-"), required=False
172-
)
173-
for x in mgr_cls._optional_get_attrs
174-
]
168+
for x in mgr_cls._optional_get_attrs:
169+
sub_parser_action.add_argument(
170+
"--%s" % x.replace("_", "-"), required=False
171+
)
175172

176173
if action_name == "create":
177174
for x in mgr_cls._create_attrs.required:

0 commit comments

Comments
 (0)