diff options
author | John L. Villalovos <john@sodarock.com> | 2021-04-24 12:48:41 -0700 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2021-04-24 12:55:32 -0700 |
commit | 3c1a0b3ba1f529fab38829c9d355561fd36f4f5d (patch) | |
tree | 42a35b6eb7b94a3e51d9182914f456e00667e85e /gitlab/v4/cli.py | |
parent | cfc42d246a4fc9a9afa9a676efcac0774e909aab (diff) | |
download | gitlab-3c1a0b3ba1f529fab38829c9d355561fd36f4f5d.tar.gz |
chore: make Get.*Mixin._optional_get_attrs always present
Always create GetMixin/GetWithoutIdMixin._optional_get_attrs attribute
with a default value of tuple()
This way we don't need to use hasattr() and we will know the type of
the attribute.
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r-- | gitlab/v4/cli.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index d036d12..70986f7 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -168,13 +168,10 @@ def _populate_sub_parser_by_class(cls, sub_parser): id_attr = cls._id_attr.replace("_", "-") sub_parser_action.add_argument("--%s" % id_attr, required=True) - if hasattr(mgr_cls, "_optional_get_attrs"): - [ - sub_parser_action.add_argument( - "--%s" % x.replace("_", "-"), required=False - ) - for x in mgr_cls._optional_get_attrs - ] + for x in mgr_cls._optional_get_attrs: + sub_parser_action.add_argument( + "--%s" % x.replace("_", "-"), required=False + ) if action_name == "create": for x in mgr_cls._create_attrs.required: |