From a622448ea5b98b4056e51175a02e301813678fdd Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Mon, 9 Feb 2026 14:50:41 +0100 Subject: [PATCH] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20src/text?= =?UTF-8?q?=5Ftable/=5Fcore.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/text_table/_core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/text_table/_core.py b/src/text_table/_core.py index e935f9e..973ad32 100644 --- a/src/text_table/_core.py +++ b/src/text_table/_core.py @@ -1,3 +1,5 @@ +from typing import Sequence + __all__ = [ 'TableBorderCharset', 'BORDER_THIN', @@ -81,19 +83,18 @@ BORDER_ROUND = TableBorderCharset( '┼' ) -def _get_max_widths(data: dict) -> dict: +def _get_max_widths(data: Sequence[dict]) -> dict: max_widths = {} for row in data: for col in row: max_widths[col] = max(len(str(row[col])), max_widths.get(col, 0)) return max_widths -def table(data: dict, *, borders: bool = False, border_charset: TableBorderCharset = BORDER_THIN, column_space: int = 1, uppercase_column_headers: bool = True) -> str: +def table(data: Sequence[dict], *, borders: bool = False, border_charset: TableBorderCharset = BORDER_THIN, column_space: int = 1, uppercase_column_headers: bool = True) -> str: ''' Creates a text table. :param data: The data. - :type data: dict :param borders: If True, the table will have borders, otherwise it will not have any borders. :type borders: bool :param border_charset: The charset for the borders. @@ -130,7 +131,6 @@ def table(data: dict, *, borders: bool = False, border_charset: TableBorderChars table += border_charset.line_vertical + ' ' if borders: table_without_borders = table - table_width = max([len(r) for r in table_without_borders.split('\n')]) table = border_charset.corner_top_left for col in columns: table += border_charset.line_horizontal * (column_widths[col] + 2)