1+ from __future__ import annotations
2+
13from math import ceil , floor
2- from typing import Callable , List , Optional , Union
34
45from .alignment import Alignment
56from .annotations import SupportsStr
@@ -13,9 +14,9 @@ class TableToAscii:
1314
1415 def __init__ (
1516 self ,
16- header : Optional [ List [ SupportsStr ]] ,
17- body : Optional [ List [ List [ SupportsStr ]]] ,
18- footer : Optional [ List [ SupportsStr ]] ,
17+ header : list [ SupportsStr ] | None ,
18+ body : list [ list [ SupportsStr ]] | None ,
19+ footer : list [ SupportsStr ] | None ,
1920 options : Options ,
2021 ):
2122 """
@@ -92,7 +93,7 @@ def __count_columns(self) -> int:
9293 return len (self .__body [0 ])
9394 return 0
9495
95- def __auto_column_widths (self ) -> List [int ]:
96+ def __auto_column_widths (self ) -> list [int ]:
9697 """
9798 Get the minimum number of characters needed for the values in
9899 each column in the table with 1 space of padding on each side.
@@ -151,7 +152,7 @@ def __row_to_ascii(
151152 heading_col_sep : str ,
152153 column_seperator : str ,
153154 right_edge : str ,
154- filler : Union [ str , List ],
155+ filler : str | list [ SupportsStr ],
155156 ) -> str :
156157 """
157158 Assembles a line of text in the ascii table
@@ -235,7 +236,7 @@ def __bottom_edge_to_ascii(self) -> str:
235236 filler = self .__style .top_and_bottom_edge ,
236237 )
237238
238- def __heading_row_to_ascii (self , row : List ) -> str :
239+ def __heading_row_to_ascii (self , row : list [ SupportsStr ] ) -> str :
239240 """
240241 Assembles the header or footer row line of the ascii table
241242
@@ -265,7 +266,7 @@ def __heading_sep_to_ascii(self) -> str:
265266 filler = self .__style .heading_row_sep ,
266267 )
267268
268- def __body_to_ascii (self , body : List [ List [SupportsStr ]]) -> str :
269+ def __body_to_ascii (self , body : list [ list [SupportsStr ]]) -> str :
269270 """
270271 Assembles the body of the ascii table
271272
@@ -317,14 +318,14 @@ def to_ascii(self) -> str:
317318
318319
319320def table2ascii (
320- header : Optional [ List [ SupportsStr ]] = None ,
321- body : Optional [ List [ List [ SupportsStr ]]] = None ,
322- footer : Optional [ List [ SupportsStr ]] = None ,
321+ header : list [ SupportsStr ] | None = None ,
322+ body : list [ list [ SupportsStr ]] | None = None ,
323+ footer : list [ SupportsStr ] | None = None ,
323324 * ,
324325 first_col_heading : bool = False ,
325326 last_col_heading : bool = False ,
326- column_widths : Optional [ List [ Optional [ int ]]] = None ,
327- alignments : Optional [ List [ Alignment ]] = None ,
327+ column_widths : list [ int | None ] | None = None ,
328+ alignments : list [ Alignment ] | None = None ,
328329 cell_padding : int = 1 ,
329330 style : TableStyle = PresetStyle .double_thin_compact ,
330331) -> str :
0 commit comments