Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py

changeset 6182
f293e95b914d
parent 6180
8d72871c16ba
child 6183
29384109306c
equal deleted inserted replaced
6181:2ae7e332b941 6182:f293e95b914d
33 "M621", "M622", "M623", "M624", "M625", 33 "M621", "M622", "M623", "M624", "M625",
34 "M631", "M632", 34 "M631", "M632",
35 "M651", "M652", "M653", "M654", "M655", 35 "M651", "M652", "M653", "M654", "M655",
36 36
37 "M701", "M702", 37 "M701", "M702",
38 "M711",
38 39
39 "M801", 40 "M801",
40 "M811", 41 "M811",
41 "M821", "M822", 42 "M821", "M822",
42 43
109 (self.__checkFormatString, ("M611", "M612", "M613", 110 (self.__checkFormatString, ("M611", "M612", "M613",
110 "M621", "M622", "M623", "M624", "M625", 111 "M621", "M622", "M623", "M624", "M625",
111 "M631", "M632")), 112 "M631", "M632")),
112 (self.__checkLogging, ("M651", "M652", "M653", "M654", "M655")), 113 (self.__checkLogging, ("M651", "M652", "M653", "M654", "M655")),
113 (self.__checkFuture, ("M701", "M702")), 114 (self.__checkFuture, ("M701", "M702")),
115 (self.__checkGettext, ("M711",)),
114 (self.__checkPrintStatements, ("M801",)), 116 (self.__checkPrintStatements, ("M801",)),
115 (self.__checkTuple, ("M811", )), 117 (self.__checkTuple, ("M811", )),
116 (self.__checkMutableDefault, ("M821", "M822")), 118 (self.__checkMutableDefault, ("M821", "M822")),
117 ] 119 ]
118 120
653 """ 655 """
654 visitor = LoggingVisitor() 656 visitor = LoggingVisitor()
655 visitor.visit(self.__tree) 657 visitor.visit(self.__tree)
656 for node, reason in visitor.violations: 658 for node, reason in visitor.violations:
657 self.__error(node.lineno - 1, node.col_offset, reason) 659 self.__error(node.lineno - 1, node.col_offset, reason)
660
661 def __checkGettext(self):
662 """
663 Private method to check the 'gettext' import statement.
664 """
665 for node in ast.walk(self.__tree):
666 if isinstance(node, ast.ImportFrom) and \
667 any(name.asname == '_' for name in node.names):
668 self.__error(node.lineno - 1, node.col_offset, "M711",
669 node.names[0].name)
658 670
659 671
660 class TextVisitor(ast.NodeVisitor): 672 class TextVisitor(ast.NodeVisitor):
661 """ 673 """
662 Class implementing a node visitor for bytes and str instances. 674 Class implementing a node visitor for bytes and str instances.

eric ide

mercurial