--- a/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py Thu Mar 08 19:03:19 2018 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py Fri Mar 09 18:54:34 2018 +0100 @@ -616,13 +616,30 @@ self.__error(default.lineno - 1, default.col_offset, errorCode, typeName) + def __dictShouldBeChecked(self, node): + """ + Private function to test, if the node should be checked. + + @param node reference to the AST node + @return flag indicating to check the node + @rtype bool + """ + if not all(isinstance(key, ast.Str) for key in node.keys): + return False + + if "__IGNORE_WARNING__" in self.__source[node.lineno - 1] or \ + "__IGNORE_WARNING_M201__" in self.__source[node.lineno - 1]: + return False + + lineNumbers = [key.lineno for key in node.keys] + return len(lineNumbers) == len(set(lineNumbers)) + def __checkDictWithSortedKeys(self): """ Private method to check, if dictionary keys appear in sorted order. """ for node in ast.walk(self.__tree): - if isinstance(node, ast.Dict) and \ - all(isinstance(key, ast.Str) for key in node.keys): + if isinstance(node, ast.Dict) and self.__dictShouldBeChecked(node): for key1, key2 in zip(node.keys, node.keys[1:]): if key2.s < key1.s: self.__error(key2.lineno - 1, key2.col_offset,