Skip to content

Commit 8c55379

Browse files
authored
Merge pull request #444 from boriel/feature/refactorize_make_sentence
Feature/refactorize make sentence
2 parents 78bb500 + 7e2098b commit 8c55379

5 files changed

Lines changed: 89 additions & 87 deletions

File tree

src/api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@
1212
from src.api import debug # noqa
1313
from src.api import errors # noqa
1414
from src.api import errmsg # noqa
15-
from src.api import symboltable # noqa

src/ast/tree.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4+
import collections
5+
6+
from typing import Iterable
7+
from typing import List
48
from typing import Optional
59

6-
import collections
710
from 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

Comments
 (0)