@@ -56,7 +56,9 @@ def __repr__(self) -> str:
5656 return f"{ type (self ).__name__ } ({ current } )"
5757
5858
59- def html_to_vdom (html : str , * transforms : _ModelTransform , strict : bool = True ) -> VdomDict :
59+ def html_to_vdom (
60+ html : str , * transforms : _ModelTransform , strict : bool = True
61+ ) -> VdomDict :
6062 """Transform HTML into a DOM model. Unique keys can be provided to HTML elements
6163 using a ``key=...`` attribute within your HTML tag.
6264
@@ -82,7 +84,9 @@ def html_to_vdom(html: str, *transforms: _ModelTransform, strict: bool = True) -
8284 recover = not strict ,
8385 )
8486 try :
85- nodes : List = fragments_fromstring (html , no_leading_text = True , parser = parser )
87+ nodes : list [etree ._Element ] = fragments_fromstring (
88+ html , no_leading_text = True , parser = parser
89+ )
8690 except etree .XMLSyntaxError as e :
8791 if not strict :
8892 raise e # pragma: no cover
@@ -139,10 +143,11 @@ def _etree_to_vdom(
139143 attributes = dict (node .items ())
140144 key = attributes .pop ("key" , None )
141145
146+ vdom : VdomDict
142147 if hasattr (idom .html , node .tag ):
143148 vdom = getattr (idom .html , node .tag )(attributes , * children , key = key )
144149 else :
145- vdom : VdomDict = {"tagName" : node .tag }
150+ vdom = {"tagName" : node .tag }
146151 if children :
147152 vdom ["children" ] = children
148153 if attributes :
@@ -160,7 +165,7 @@ def _etree_to_vdom(
160165 return vdom
161166
162167
163- def _mutate_vdom (vdom : VdomDict ):
168+ def _mutate_vdom (vdom : VdomDict ) -> None :
164169 """Performs any necessary mutations on the VDOM attributes to meet VDOM spec.
165170
166171 Currently, this function only transforms the ``style`` attribute into a dictionary whose keys are
@@ -216,5 +221,5 @@ def _hypen_to_camel_case(string: str) -> str:
216221 return first .lower () + remainder .title ().replace ("-" , "" )
217222
218223
219- class HTMLParseError (etree .LxmlSyntaxError ):
224+ class HTMLParseError (etree .LxmlSyntaxError ): # type: ignore[misc]
220225 """Raised when an HTML document cannot be parsed using strict parsing."""
0 commit comments