summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-04-24 12:24:49 -0700
committerJohn L. Villalovos <john@sodarock.com>2021-04-24 12:26:46 -0700
commit89331131b3337308bacb0c4013e80a4809f3952c (patch)
tree7cbe735bba997e61294df720db03616763787a8d
parentcfc42d246a4fc9a9afa9a676efcac0774e909aab (diff)
downloadgitlab-89331131b3337308bacb0c4013e80a4809f3952c.tar.gz
chore: make ListMixin._list_filters always present
Always create ListMixin._list_filters 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.
-rw-r--r--gitlab/mixins.py2
-rw-r--r--gitlab/v4/cli.py11
2 files changed, 6 insertions, 7 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index a22fea4..4c3e46e 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -22,6 +22,7 @@ from typing import (
Dict,
List,
Optional,
+ Tuple,
Type,
TYPE_CHECKING,
Union,
@@ -186,6 +187,7 @@ class RefreshMixin(_RestObjectBase):
class ListMixin(_RestManagerBase):
_computed_path: Optional[str]
_from_parent_attrs: Dict[str, Any]
+ _list_filters: Tuple[str, ...] = ()
_obj_cls: Optional[Type[base.RESTObject]]
_parent: Optional[base.RESTObject]
_parent_attrs: Dict[str, Any]
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index d036d12..705916e 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -145,13 +145,10 @@ def _populate_sub_parser_by_class(cls, sub_parser):
)
if action_name == "list":
- if hasattr(mgr_cls, "_list_filters"):
- [
- sub_parser_action.add_argument(
- "--%s" % x.replace("_", "-"), required=False
- )
- for x in mgr_cls._list_filters
- ]
+ for x in mgr_cls._list_filters:
+ sub_parser_action.add_argument(
+ "--%s" % x.replace("_", "-"), required=False
+ )
sub_parser_action.add_argument("--page", required=False)
sub_parser_action.add_argument("--per-page", required=False)