18 Class implementing a checker for to help simplifying Python code. |
18 Class implementing a checker for to help simplifying Python code. |
19 """ |
19 """ |
20 Codes = [ |
20 Codes = [ |
21 # Python-specifics |
21 # Python-specifics |
22 "Y101", "Y102", "Y103", "Y104", "Y105", "Y106", "Y107", "Y108", |
22 "Y101", "Y102", "Y103", "Y104", "Y105", "Y106", "Y107", "Y108", |
23 "Y109", "Y110", "Y111", "Y112", |
23 "Y109", "Y110", "Y111", "Y112", "Y113", "Y114", "Y115", "Y116", |
24 |
24 |
25 # Comparations |
25 # Comparations |
26 ] |
26 ] |
27 |
27 |
28 def __init__(self, source, filename, selected, ignored, expected, repeat): |
28 def __init__(self, source, filename, selected, ignored, expected, repeat): |
147 self.__tree = self.__generateTree() |
147 self.__tree = self.__generateTree() |
148 except (SyntaxError, TypeError): |
148 except (SyntaxError, TypeError): |
149 self.__reportInvalidSyntax() |
149 self.__reportInvalidSyntax() |
150 return |
150 return |
151 |
151 |
|
152 # Add parent information |
|
153 for node in ast.walk(self.__tree): |
|
154 for child in ast.iter_child_nodes(node): |
|
155 child.parent = node # type: ignore |
|
156 |
152 visitor = SimplifyNodeVisitor(self.__error) |
157 visitor = SimplifyNodeVisitor(self.__error) |
153 visitor.visit(self.__tree) |
158 visitor.visit(self.__tree) |