src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py

branch
eric7
changeset 10355
f3187412ecf4
parent 10175
57ed3cb66e9a
child 10359
de0420dac60e
diff -r 49a439993d06 -r f3187412ecf4 src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py	Wed Nov 29 14:29:44 2023 +0100
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py	Wed Nov 29 14:31:31 2023 +0100
@@ -22,7 +22,7 @@
 import AstUtilities
 
 ###############################################################################
-## adapted from: flake8-simplify v0.20.0
+## adapted from: flake8-simplify v0.21.0
 ##
 ## Original License:
 ##
@@ -181,6 +181,7 @@
         self.__check905(node)
         self.__check906(node)
         self.__check910(node)
+        self.__check911(node)
 
         self.generic_visit(node)
 
@@ -1900,6 +1901,35 @@
         expected = f"{func}({key})"
         self.__error(node.lineno - 1, node.col_offset, "Y910", expected, actual)
 
+    def __check911(self, node):
+        """
+        Private method to check for the expression "zip(_.keys(), _.values())".
+
+        @param node reference to the AST node to be checked
+        @type ast.Call
+        """
+        if isinstance(node, ast.Call) and (
+            isinstance(node.func, ast.Name)
+            and node.func.id == "zip"
+            and len(node.args) == 2
+        ):
+            firstArg, secondArg = node.args
+            if (
+                isinstance(firstArg, ast.Call)
+                and isinstance(firstArg.func, ast.Attribute)
+                and isinstance(firstArg.func.value, ast.Name)
+                and firstArg.func.attr == "keys"
+                and isinstance(secondArg, ast.Call)
+                and isinstance(secondArg.func, ast.Attribute)
+                and isinstance(secondArg.func.value, ast.Name)
+                and secondArg.func.attr == "values"
+                and firstArg.func.value.id == secondArg.func.value.id
+            ):
+                self.__error(
+                    node.lineno - 1, node.col_offset, "Y911", firstArg.func.value.id
+                )
+
+
 
 #
 # eflag: noqa = M891

eric ide

mercurial