@@ -28,16 +28,6 @@ def __init__(self, nid=None):
28
28
def __iter__ (self ):
29
29
return iter (self .children )
30
30
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
-
41
31
def accept (self , visitor , * args , ** kwargs ):
42
32
func = getattr (visitor , f"visit_{ self .visitor_name } " )
43
33
return func (self , * args , ** kwargs )
@@ -62,10 +52,16 @@ def __init__(self, children=(), **kwargs):
62
52
else :
63
53
self .add_text (child )
64
54
65
- def append (self , child ) :
66
- """overridden to detect problems easily """
55
+ def append (self , child : VNode ) -> None :
56
+ """add a node to children """
67
57
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
69
65
70
66
def parents (self ):
71
67
"""return the ancestor nodes"""
0 commit comments