Thu, 16 Mar 2017 19:58:22 +0100
Removed obsolete checker for M121 (blind except) because that is already checked by pycodestyle.
Added an exception to M131 to ignore Python2 compatibility assignements like "str = unicode".
--- 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)):
--- a/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Thu Mar 16 19:32:33 2017 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Thu Mar 16 19:58:22 2017 +0100 @@ -438,9 +438,6 @@ "M112": QCoreApplication.translate( "MiscellaneousChecker", "copyright notice contains invalid author"), - "M121": QCoreApplication.translate( - "MiscellaneousChecker", - "blind except: statement"), # __IGNORE_WARNING_M121__ "M131": QCoreApplication.translate( "MiscellaneousChecker", '"{0}" is a Python builtin and is being shadowed; '