Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py

changeset 5617
1b9e3d94864a
parent 5589
ad8f37c6a306
child 5619
ab999dc48132
--- a/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Thu Mar 16 19:32:33 2017 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Thu Mar 16 19:58:22 2017 +0100
@@ -21,7 +21,6 @@
     Codes = [
         "M101", "M102",
         "M111", "M112",
-        "M121",
         "M131", "M132",
         
         "M191", "M192", "M193", "M194",
@@ -77,8 +76,6 @@
         self.__source = source[:]
         self.__args = args
         
-        self.__blindExceptRegex = re.compile(
-            r'(\bexcept:)')                             # __IGNORE_WARNING__
         self.__pep3101FormatRegex = re.compile(
             r'^(?:[^\'"]*[\'"][^\'"]*[\'"])*\s*%|^\s*%')
         
@@ -100,7 +97,6 @@
         checkersWithCodes = [
             (self.__checkCoding, ("M101", "M102")),
             (self.__checkCopyright, ("M111", "M112")),
-            (self.__checkBlindExcept, ("M121",)),
             (self.__checkBuiltins, ("M131", "M132")),
             (self.__checkComprehensions, ("M191", "M192", "M193", "M194",
                                           "M195", "M196", "M197", "M198")),
@@ -280,15 +276,6 @@
             if not copyrightAuthorRe.search(topOfSource):
                 self.__error(0, 0, "M112")
     
-    def __checkBlindExcept(self):
-        """
-        Private method to check for blind except statements.
-        """
-        for lineno, line in enumerate(self.__source):
-            match = self.__blindExceptRegex.search(line)
-            if match:
-                self.__error(lineno, match.start(), "M121")
-    
     def __checkPrintStatements(self):
         """
         Private method to check for print statements.
@@ -510,6 +497,12 @@
                 for element in node.targets:
                     if isinstance(element, ast.Name) and \
                        element.id in self.__builtins:
+                        value = node.value
+                        if isinstance(value, ast.Name) and \
+                           value.id in ["unicode", "unichr"]:
+                            # ignore compatibility assignments
+                            # TODO: make this configurable
+                            continue
                         self.__error(element.lineno - 1, element.col_offset,
                                      "M131", element.id)
                     elif isinstance(element, (ast.Tuple, ast.List)):

eric ide

mercurial