@@ -102,36 +102,37 @@ def parse_nptable(block: "BlockParser", m: Match[str], state: "BlockState") -> O
102102 return pos
103103
104104
105- def _process_thead (header : str , align : str ) -> Union [Tuple [None , None ], Tuple [Dict [str , Any ], List [str ]]]:
105+ def _process_thead (header : str , align : str ) -> Union [Tuple [None , None ], Tuple [Dict [str , Any ], List [Optional [ str ] ]]]:
106106 headers = _split_table_cells (header )
107- aligns = _split_table_cells (align )
108- if len (headers ) != len (aligns ):
107+ raw_aligns = _split_table_cells (align )
108+ if len (headers ) != len (raw_aligns ):
109109 return None , None
110110
111- for i , v in enumerate (aligns ):
111+ aligns : List [Optional [str ]] = []
112+ for v in raw_aligns :
112113 if ALIGN_CENTER .match (v ):
113- aligns [ i ] = "center"
114+ aligns . append ( "center" )
114115 elif ALIGN_LEFT .match (v ):
115- aligns [ i ] = "left"
116+ aligns . append ( "left" )
116117 elif ALIGN_RIGHT .match (v ):
117- aligns [ i ] = "right"
118+ aligns . append ( "right" )
118119 else :
119- aligns [ i ] = None
120+ aligns . append ( None )
120121
121- children = [
122+ children : List [ Dict [ str , Any ]] = [
122123 {"type" : "table_cell" , "text" : text .strip (), "attrs" : {"align" : aligns [i ], "head" : True }}
123124 for i , text in enumerate (headers )
124125 ]
125- thead = {"type" : "table_head" , "children" : children }
126+ thead : Dict [ str , Any ] = {"type" : "table_head" , "children" : children }
126127 return thead , aligns
127128
128129
129- def _process_row (text : str , aligns : List [str ]) -> Optional [Dict [str , Any ]]:
130+ def _process_row (text : str , aligns : List [Optional [ str ] ]) -> Optional [Dict [str , Any ]]:
130131 cells = _split_table_cells (text )
131132 if len (cells ) != len (aligns ):
132133 return None
133134
134- children = [
135+ children : List [ Dict [ str , Any ]] = [
135136 {"type" : "table_cell" , "text" : text .strip (), "attrs" : {"align" : aligns [i ], "head" : False }}
136137 for i , text in enumerate (cells )
137138 ]
0 commit comments