Skip to content

Commit 46b091f

Browse files
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. Closes: #2287
1 parent 1714d0a commit 46b091f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gitlab/v4/cli.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
387387

388388

389389
def get_dict(
390-
obj: Union[str, gitlab.base.RESTObject], fields: List[str]
390+
obj: Union[str, Dict[str, Any], gitlab.base.RESTObject], fields: List[str]
391391
) -> Union[str, Dict[str, Any]]:
392-
if isinstance(obj, str):
392+
if not isinstance(obj, gitlab.base.RESTObject):
393393
return obj
394394

395395
if fields:
@@ -406,7 +406,7 @@ def display(d: Union[str, Dict[str, Any]], **_kwargs: Any) -> None:
406406

407407
@staticmethod
408408
def display_list(
409-
data: List[Union[str, gitlab.base.RESTObject]],
409+
data: List[Union[str, Dict[str, Any], gitlab.base.RESTObject]],
410410
fields: List[str],
411411
**_kwargs: Any,
412412
) -> None:
@@ -431,7 +431,7 @@ def display(d: Union[str, Dict[str, Any]], **_kwargs: Any) -> None:
431431

432432
@staticmethod
433433
def display_list(
434-
data: List[Union[str, gitlab.base.RESTObject]],
434+
data: List[Union[str, Dict[str, Any], gitlab.base.RESTObject]],
435435
fields: List[str],
436436
**_kwargs: Any,
437437
) -> None:

0 commit comments

Comments
 (0)