Simplify Checker: fixed an issue in check 122.

Sat, 10 Apr 2021 17:54:58 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 10 Apr 2021 17:54:58 +0200
changeset 8216
6a042a54e0f7
parent 8215
fc5d68a6889e
child 8217
385f60c94548

Simplify Checker: fixed an issue in check 122.

eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py file | annotate | diff | comparison | revisions
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py	Sat Apr 10 16:13:22 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py	Sat Apr 10 17:54:58 2021 +0200
@@ -24,7 +24,7 @@
         "Y117", "Y118", "Y119", "Y120", "Y121", "Y122",
        
         # Python-specifics not part of flake8-simplify
-       "Y181", "Y182",
+        "Y181", "Y182",
         
         # Comparations
         "Y201", "Y202", "Y203", "Y204", "Y205", "Y206", "Y207", "Y208",
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py	Sat Apr 10 16:13:22 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py	Sat Apr 10 17:54:58 2021 +0200
@@ -1122,7 +1122,10 @@
             isinstance(node.body[0], ast.Assign) and
             isinstance(node.body[0].value, ast.Subscript) and
             len(node.body[0].targets) == 1 and
-            isinstance(node.body[0].targets[0], ast.Name)
+            isinstance(node.body[0].targets[0], ast.Name) and
+            isinstance(node.body[0].value.value, ast.Name) and
+            isinstance(node.test.comparators[0], ast.Name) and
+            node.body[0].value.value.id == node.test.comparators[0].id
         ):
             key = unparse(node.test.left)
             dictname = unparse(node.test.comparators[0])

eric ide

mercurial