From 5e6241652b4b10378ff762654280cfae7a297e87 Mon Sep 17 00:00:00 2001 From: Michael Waskom Date: Thu, 9 May 2024 14:06:22 +0000 Subject: [PATCH] Expand display_table column type annotation --- modal/cli/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modal/cli/utils.py b/modal/cli/utils.py index 4f133cf12..957a679a7 100644 --- a/modal/cli/utils.py +++ b/modal/cli/utils.py @@ -5,7 +5,7 @@ import typer from rich.console import Console from rich.json import JSON -from rich.table import Table +from rich.table import Column, Table from rich.text import Text @@ -26,14 +26,17 @@ def _plain(text: Union[Text, str]) -> str: def display_table( - column_names: List[str], rows: Sequence[Sequence[Union[Text, str]]], json: bool = False, title: str = None + columns: List[Union[str, Column]], + rows: Sequence[Sequence[Union[Text, str]]], + json: bool = False, + title: str = None, ): console = Console() if json: - json_data = [{col: _plain(row[i]) for i, col in enumerate(column_names)} for row in rows] + json_data = [{col: _plain(row[i]) for i, col in enumerate(columns)} for row in rows] console.print(JSON.from_data(json_data)) else: - table = Table(*column_names, title=title) + table = Table(*columns, title=title) for row in rows: table.add_row(*row) console.print(table)