1111import tempfile
1212import urllib .parse
1313import webbrowser
14- from collections import UserString
14+ from collections import UserList , UserString
1515from copy import copy , deepcopy
1616from pathlib import Path
1717from typing import (
1818 Any ,
1919 Callable ,
2020 Dict ,
2121 Iterable ,
22- List ,
2322 Mapping ,
2423 Optional ,
2524 Sequence ,
@@ -255,7 +254,7 @@ def _repr_html_(self) -> str: ...
255254# =============================================================================
256255# TagList class
257256# =============================================================================
258- class TagList (List [TagNode ]):
257+ class TagList (UserList [TagNode ]):
259258 """
260259 Create an HTML tag list (i.e., a fragment of HTML)
261260
@@ -275,26 +274,26 @@ class TagList(List[TagNode]):
275274 def __init__ (self , * args : TagChild ) -> None :
276275 super ().__init__ (_tagchilds_to_tagnodes (args ))
277276
278- def extend (self , x : Iterable [TagChild ]) -> None :
277+ def extend (self , other : Iterable [TagChild ]) -> None :
279278 """
280279 Extend the children by appending an iterable of children.
281280 """
282281
283- super ().extend (_tagchilds_to_tagnodes (x ))
282+ super ().extend (_tagchilds_to_tagnodes (other ))
284283
285- def append (self , * args : TagChild ) -> None :
284+ def append (self , item : TagChild , * args : TagChild ) -> None :
286285 """
287286 Append tag children to the end of the list.
288287 """
289288
290- self .extend (args )
289+ self .extend ([ item , * args ] )
291290
292- def insert (self , index : SupportsIndex , x : TagChild ) -> None :
291+ def insert (self , i : SupportsIndex , item : TagChild ) -> None :
293292 """
294293 Insert tag children before a given index.
295294 """
296295
297- self [ index : index ] = _tagchilds_to_tagnodes ([x ])
296+ self . data [ i : i ] = _tagchilds_to_tagnodes ([item ])
298297
299298 def tagify (self ) -> "TagList" :
300299 """
@@ -306,16 +305,16 @@ def tagify(self) -> "TagList":
306305 # Iterate backwards because if we hit a Tagifiable object, it may be replaced
307306 # with 0, 1, or more items (if it returns TagList).
308307 for i in reversed (range (len (cp ))):
309- child = cp [i ]
308+ child = cp . data [i ]
310309
311310 if isinstance (child , Tagifiable ):
312311 tagified_child = child .tagify ()
313312 if isinstance (tagified_child , TagList ):
314313 # If the Tagifiable object returned a TagList, flatten it into this
315314 # one.
316- cp [i : i + 1 ] = _tagchilds_to_tagnodes (tagified_child )
315+ cp . data [i : i + 1 ] = _tagchilds_to_tagnodes (tagified_child )
317316 else :
318- cp [i ] = tagified_child
317+ cp . data [i ] = tagified_child
319318
320319 elif isinstance (child , MetadataNode ):
321320 cp [i ] = copy (child )
@@ -342,7 +341,7 @@ def save_html(
342341 The path to the generated HTML file.
343342 """
344343
345- return HTMLDocument (self ).save_html (
344+ return HTMLDocument (self . data ).save_html (
346345 file , libdir = libdir , include_version = include_version
347346 )
348347
@@ -382,7 +381,7 @@ def get_html_string(
382381 first_child = True
383382 prev_was_add_ws = add_ws
384383
385- for child in self :
384+ for child in self . data :
386385 if isinstance (child , MetadataNode ):
387386 continue
388387
@@ -447,7 +446,7 @@ def get_dependencies(self, *, dedup: bool = True) -> list["HTMLDependency"]:
447446 """
448447
449448 deps : list [HTMLDependency ] = []
450- for x in self :
449+ for x in self . data :
451450 if isinstance (x , HTMLDependency ):
452451 deps .append (x )
453452 elif isinstance (x , Tag ):
0 commit comments