eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py

changeset 8191
9125da0c227e
parent 8189
17df5c8df8c1
child 8192
e1157bd8b4c2
equal deleted inserted replaced
8189:17df5c8df8c1 8191:9125da0c227e
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)

eric ide

mercurial