@@ -28,16 +28,6 @@ def __init__(self, nid=None):
2828 def __iter__ (self ):
2929 return iter (self .children )
3030
31- def append (self , child ):
32- """add a node to children"""
33- self .children .append (child )
34- child .parent = self
35-
36- def insert (self , index , child ):
37- """insert a child node"""
38- self .children .insert (index , child )
39- child .parent = self
40-
4131 def accept (self , visitor , * args , ** kwargs ):
4232 func = getattr (visitor , f"visit_{ self .visitor_name } " )
4333 return func (self , * args , ** kwargs )
@@ -62,10 +52,16 @@ def __init__(self, children=(), **kwargs):
6252 else :
6353 self .add_text (child )
6454
65- def append (self , child ) :
66- """overridden to detect problems easily """
55+ def append (self , child : VNode ) -> None :
56+ """add a node to children """
6757 assert child not in self .parents ()
68- VNode .append (self , child )
58+ self .children .append (child )
59+ child .parent = self
60+
61+ def insert (self , index : int , child : VNode ) -> None :
62+ """insert a child node"""
63+ self .children .insert (index , child )
64+ child .parent = self
6965
7066 def parents (self ):
7167 """return the ancestor nodes"""
0 commit comments