@@ -482,23 +482,35 @@ def display_dict(d: Dict[str, Any], padding: int) -> None:
482
482
if obj ._id_attr :
483
483
attrs .pop (obj ._id_attr )
484
484
display_dict (attrs , padding )
485
+ return
485
486
486
- else :
487
- if TYPE_CHECKING :
488
- assert isinstance (obj , gitlab .base .RESTObject )
489
- if obj ._id_attr :
490
- id = getattr (obj , obj ._id_attr )
491
- print (f"{ obj ._id_attr .replace ('_' , '-' )} : { id } " )
492
- if obj ._repr_attr :
493
- value = getattr (obj , obj ._repr_attr , "None" ) or "None"
494
- value = value .replace ("\r " , "" ).replace ("\n " , " " )
495
- # If the attribute is a note (ProjectCommitComment) then we do
496
- # some modifications to fit everything on one line
497
- line = f"{ obj ._repr_attr } : { value } "
498
- # ellipsize long lines (comments)
499
- if len (line ) > 79 :
500
- line = f"{ line [:76 ]} ..."
501
- print (line )
487
+ lines = []
488
+
489
+ if TYPE_CHECKING :
490
+ assert isinstance (obj , gitlab .base .RESTObject )
491
+
492
+ if obj ._id_attr :
493
+ id = getattr (obj , obj ._id_attr )
494
+ lines .append (f"{ obj ._id_attr .replace ('_' , '-' )} : { id } " )
495
+ if obj ._repr_attr :
496
+ value = getattr (obj , obj ._repr_attr , "None" ) or "None"
497
+ value = value .replace ("\r " , "" ).replace ("\n " , " " )
498
+ # If the attribute is a note (ProjectCommitComment) then we do
499
+ # some modifications to fit everything on one line
500
+ line = f"{ obj ._repr_attr } : { value } "
501
+ # ellipsize long lines (comments)
502
+ if len (line ) > 79 :
503
+ line = f"{ line [:76 ]} ..."
504
+ lines .append (line )
505
+
506
+ if lines :
507
+ print ("\n " .join (lines ))
508
+ return
509
+
510
+ print (
511
+ f"No default fields to show for { obj !r} . "
512
+ f"Please use '--verbose' or the JSON/YAML formatters."
513
+ )
502
514
503
515
def display_list (
504
516
self ,
0 commit comments