11#!/usr/bin/python
22# -*- coding: utf-8 -*-
33
4+ import collections
5+
6+ from typing import Iterable
7+ from typing import List
48from typing import Optional
59
6- import collections
710from src .api .errors import Error
811
912__all__ = ['NotAnAstError' , 'Tree' ]
@@ -30,7 +33,7 @@ class ChildrenList:
3033 def __init__ (self , node : 'Tree' ):
3134 assert isinstance (node , Tree )
3235 self .parent = node # Node having this children
33- self ._children = []
36+ self ._children : List [ 'Tree' ] = []
3437
3538 def __getitem__ (self , key ):
3639 if isinstance (key , int ):
@@ -91,8 +94,8 @@ def children(self):
9194 return self ._children
9295
9396 @children .setter
94- def children (self , value ):
95- assert isinstance (value , collections .abc . Iterable )
97+ def children (self , value : Iterable ):
98+ assert isinstance (value , collections .Iterable )
9699 while len (self .children ):
97100 self .children .pop ()
98101
@@ -124,12 +127,12 @@ def postorder(self):
124127
125128 yield self
126129
127- def appendChild (self , node ):
130+ def appendChild (self , node : 'Tree' ):
128131 """ Appends the given node to the current children list
129132 """
130133 self .children .append (node )
131134
132- def prependChild (self , node ):
135+ def prependChild (self , node : 'Tree' ):
133136 """ Inserts the given node at the beginning of the children list
134137 """
135138 self .children .insert (0 , node )
0 commit comments