1- from typing import List , Optional , Union
1+ from typing import Any , List , Optional , Union
22
33import attr
44
@@ -15,7 +15,7 @@ class Token:
1515 # - `-1` means the tag is closing
1616 nesting : int = attr .ib ()
1717 # Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
18- attrs : Optional [list ] = attr .ib (default = None )
18+ attrs : Optional [List [ list ] ] = attr .ib (default = None )
1919 # Source map info. Format: `[ line_begin, line_end ]`
2020 map : Optional [List [int ]] = attr .ib (default = None )
2121 # nesting level, the same as `state.level`
@@ -46,14 +46,14 @@ def attrIndex(self, name: str) -> int:
4646 return i
4747 return - 1
4848
49- def attrPush (self , attrData : List [ str ]) :
49+ def attrPush (self , attrData : list ) -> None :
5050 """Add `[ name, value ]` attribute to list. Init attrs if necessary."""
5151 if self .attrs :
5252 self .attrs .append (attrData )
5353 else :
5454 self .attrs = [attrData ]
5555
56- def attrSet (self , name : str , value : str ) :
56+ def attrSet (self , name : str , value : Any ) -> None :
5757 """Set `name` attribute to `value`. Override old value if exists."""
5858 idx = self .attrIndex (name )
5959 if idx < 0 :
@@ -62,7 +62,7 @@ def attrSet(self, name: str, value: str):
6262 assert self .attrs is not None
6363 self .attrs [idx ] = [name , value ]
6464
65- def attrGet (self , name : str ) -> Optional [ str ] :
65+ def attrGet (self , name : str ) -> Any :
6666 """ Get the value of attribute `name`, or null if it does not exist."""
6767 idx = self .attrIndex (name )
6868 if idx >= 0 :
0 commit comments