Skip to content

Commit 11eb374

Browse files
🐛 FIX: Token.attrs type annotations (#95)
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
1 parent 031b329 commit 11eb374

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

markdown_it/token.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional, Union
1+
from typing import Any, List, Optional, Union
22

33
import 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

Comments
 (0)