[master 1/3] Check for simple function calls in pointless overrides.

mulkieran installerbot-noreply at redhat.com
Mon Mar 16 13:29:43 UTC 2015


From: mulhern <amulhern at redhat.com>

---
 tests/pylint/pointless-override.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/pylint/pointless-override.py b/tests/pylint/pointless-override.py
index c8d4776..cf2608f 100644
--- a/tests/pylint/pointless-override.py
+++ b/tests/pylint/pointless-override.py
@@ -141,6 +141,7 @@ class PointlessAssignment(PointlessData):
     message_id = "W9951"
 
     _VALUE_CLASSES = (
+        astroid.CallFunc,
         astroid.Const,
         astroid.Dict,
         astroid.List,
@@ -162,6 +163,24 @@ def check_equal(cls, node, other):
                all(cls.check_equal(n, o) for (n, o) in zip(node.elts, other.elts))
         if isinstance(node, astroid.Dict):
             return len(node.items) == len(other.items)
+        if isinstance(node, astroid.CallFunc):
+            if type(node.func) != type(other.func):
+                return False
+
+            if isinstance(node.func, astroid.Getattr):
+                if node.func.attrname != other.func.attrname or \
+                   type(node.func.expr) != type(other.func.expr) or \
+                   node.func.expr.name != other.func.expr.name:
+                    return False
+            elif isinstance(node.func, astroid.Name):
+                if node.func.name != other.func.name:
+                    return False
+            else:
+                return False
+
+            return node.starargs == other.starargs and \
+               node.kwargs == other.kwargs and \
+               all(cls.check_equal(n, o) for (n, o) in zip(node.args, other.args))
         return False
 
     @staticmethod


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/d71dd919cc991e48812fca7b42be0d37d3ae8e87


More information about the anaconda-patches mailing list