Skip to content

Commit 031b329

Browse files
👌 IMPROVE: Make NestedTokens.closing not optional (#118)
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
1 parent 2afb7cc commit 031b329

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

markdown_it/token.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class NestedTokens:
117117
"""
118118

119119
opening: Token = attr.ib()
120-
closing: Optional[Token] = attr.ib()
120+
closing: Token = attr.ib()
121121
children: List[Union[Token, "NestedTokens"]] = attr.ib(factory=list)
122122

123123
def __getattr__(self, name):
@@ -144,6 +144,9 @@ def nest_tokens(tokens: List[Token]) -> List[Union[Token, NestedTokens]]:
144144
token = token.copy()
145145
output.append(token)
146146
if token.children:
147+
# Ignore type checkers because `nest_tokens` doesn't respect
148+
# typing of `Token.children`. We add `NestedTokens` into a
149+
# `List[Token]` here.
147150
token.children = nest_tokens(token.children) # type: ignore
148151
continue
149152

0 commit comments

Comments
 (0)