From 89331131b3337308bacb0c4013e80a4809f3952c Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sat, 24 Apr 2021 12:24:49 -0700 Subject: [PATCH] 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. --- gitlab/mixins.py | 2 ++ gitlab/v4/cli.py | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gitlab/mixins.py b/gitlab/mixins.py index a22fea401..4c3e46e30 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -22,6 +22,7 @@ Dict, List, Optional, + Tuple, Type, TYPE_CHECKING, Union, @@ -186,6 +187,7 @@ def refresh(self, **kwargs: Any) -> None: 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 d036d127d..705916e60 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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy