summaryrefslogtreecommitdiff
path: root/gitlab/v4/cli.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-10-05 07:43:14 -0700
committerNejc Habjan <hab.nejc@gmail.com>2022-10-06 09:24:02 +0200
commit9b88132078ed37417c2a45369b4976c9c67f7882 (patch)
tree61f075c8d2685df36153970f2a93937ac9f14c86 /gitlab/v4/cli.py
parentc15bd33f45fbd9d064f1e173c6b3ca1b216def2f (diff)
downloadgitlab-9b88132078ed37417c2a45369b4976c9c67f7882.tar.gz
fix(cli): handle list response for json/yaml output
Handle the case with the CLI where a list response is returned from GitLab and json/yaml output is requested. Add a functional CLI test to validate it works. Closes: #2287
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r--gitlab/v4/cli.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index a4f4e2c..1a6ea39 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -387,9 +387,9 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
def get_dict(
- obj: Union[str, gitlab.base.RESTObject], fields: List[str]
+ obj: Union[str, Dict[str, Any], gitlab.base.RESTObject], fields: List[str]
) -> Union[str, Dict[str, Any]]:
- if isinstance(obj, str):
+ if not isinstance(obj, gitlab.base.RESTObject):
return obj
if fields:
@@ -406,7 +406,7 @@ class JSONPrinter:
@staticmethod
def display_list(
- data: List[Union[str, gitlab.base.RESTObject]],
+ data: List[Union[str, Dict[str, Any], gitlab.base.RESTObject]],
fields: List[str],
**_kwargs: Any,
) -> None:
@@ -431,7 +431,7 @@ class YAMLPrinter:
@staticmethod
def display_list(
- data: List[Union[str, gitlab.base.RESTObject]],
+ data: List[Union[str, Dict[str, Any], gitlab.base.RESTObject]],
fields: List[str],
**_kwargs: Any,
) -> None: