--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py Tue Aug 29 16:55:01 2023 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py Tue Aug 29 16:55:18 2023 +0200 @@ -662,7 +662,7 @@ visitor = TextVisitor() visitor.visit(self.__tree) for node in visitor.nodes: - text = node.s + text = node.value if isinstance(text, bytes): try: text = text.decode(coding) @@ -943,13 +943,11 @@ for kw in node.args[0].keywords: if kw.arg != "reverse": continue - if isinstance(kw.value, ast.NameConstant): - reverseFlagValue = kw.value.value - elif isinstance(kw.value, ast.Num): - reverseFlagValue = bool(kw.value.n) - else: - # Complex value - reverseFlagValue = None + reverseFlagValue = ( + bool(kw.value.value) + if isinstance(kw.value, ast.Constant) + else None + ) if reverseFlagValue is None: self.__error( @@ -1011,7 +1009,7 @@ and node.args[0].slice.upper is None and isinstance(node.args[0].slice.step, ast.UnaryOp) and isinstance(node.args[0].slice.step.op, ast.USub) - and isinstance(node.args[0].slice.step.operand, ast.Num) + and isinstance(node.args[0].slice.step.operand, ast.Constant) and node.args[0].slice.step.operand.n == 1 ): self.__error(node.lineno - 1, node.col_offset, "M189", node.func.id) @@ -1135,9 +1133,13 @@ for node in ast.walk(self.__tree): if isinstance(node, ast.Dict) and self.__dictShouldBeChecked(node): for key1, key2 in zip(node.keys, node.keys[1:]): - if key2.s < key1.s: + if key2.value < key1.value: self.__error( - key2.lineno - 1, key2.col_offset, "M201", key2.s, key1.s + key2.lineno - 1, + key2.col_offset, + "M201", + key2.value, + key1.value, ) def __checkLogging(self): @@ -1328,24 +1330,6 @@ node.is_docstring = False self.nodes.append(node) - def visit_Str(self, node): - """ - Public method to record a string node. - - @param node reference to the string node - @type ast.Str - """ - self.__addNode(node) - - def visit_Bytes(self, node): - """ - Public method to record a bytes node. - - @param node reference to the bytes node - @type ast.Bytes - """ - self.__addNode(node) - def visit_Constant(self, node): """ Public method to handle constant nodes. @@ -2017,7 +2001,7 @@ # bad getattr and setattr if ( node.func.id in ("getattr", "hasattr") - and node.args[1].s == "__call__" + and node.args[1].value == "__call__" ): self.violations.append((node, "M504")) if ( @@ -2636,8 +2620,7 @@ def emptyBody(body): def isStrOrEllipsis(node): - # ast.Ellipsis and ast.Str used in python<3.8 - return isinstance(node, (ast.Ellipsis, ast.Str)) or ( + return ( isinstance(node, ast.Constant) and (node.value is Ellipsis or isinstance(node.value, str)) )