11import re
2- from typing import Any , Dict , Iterable , List , Optional , Tuple , Type , TypeVar
2+ from typing import Any , Iterable , Type , TypeVar
33
44_TABLE_LINE_PATTERN = re .compile (r"\s?\|([^\|]+)" )
55_TABLE_SEPARATOR_LINE_PATTERN = re .compile (r"^[-:\s\|]*$" )
@@ -20,7 +20,7 @@ def __init__(
2020 )
2121
2222 @property
23- def rows (self ) -> Tuple [ List [Any ], ...]:
23+ def rows (self ) -> tuple [ list [Any ], ...]:
2424 return self ._rows
2525
2626 def __str__ (self ) -> str :
@@ -71,14 +71,14 @@ def __repr__(self) -> str:
7171 )
7272
7373 @property
74- def headers (self ) -> Tuple [str , ...]:
74+ def headers (self ) -> tuple [str , ...]:
7575 return self ._headers
7676
7777 @property
78- def records (self ) -> Tuple [ Tuple [str , ...], ...]:
78+ def records (self ) -> tuple [ tuple [str , ...], ...]:
7979 return self ._records
8080
81- def items (self ) -> Iterable [Dict [str , str ]]:
81+ def items (self ) -> Iterable [dict [str , str ]]:
8282 properties = {index : header for index , header in enumerate (self .headers )}
8383
8484 for record in self .records :
@@ -110,9 +110,9 @@ def __getitem__(self, key):
110110T = TypeVar ("T" , bound = Table )
111111
112112
113- def read_table (markdown : str , cls : Type [T ] = Table ) -> Optional [ T ] :
114- headers : List [str ] = []
115- records : List [ List [str ]] = []
113+ def read_table (markdown : str , cls : Type [T ] = Table ) -> T | None :
114+ headers : list [str ] = []
115+ records : list [ list [str ]] = []
116116
117117 for line in markdown .splitlines ():
118118 if _TABLE_SEPARATOR_LINE_PATTERN .match (line ):
0 commit comments