summaryrefslogtreecommitdiff
path: root/astroid/arguments.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-31 21:31:36 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-31 21:31:36 +0200
commit7a17ba37ce7a52fc82069814507c9fb65787368b (patch)
tree59ce1a64b8cb458892a33a0684e78a8bdbd06d0d /astroid/arguments.py
parent6193b56b752c81a011419feb026f8fd5d22d8163 (diff)
downloadastroid-git-7a17ba37ce7a52fc82069814507c9fb65787368b.tar.gz
Fix some inconsistencies with accessing the first argument of methods
If the current class is a metaclass (inherits from `type`), then the first argument is always a class, not an instance.
Diffstat (limited to 'astroid/arguments.py')
-rw-r--r--astroid/arguments.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/astroid/arguments.py b/astroid/arguments.py
index 5670fa86..e80f5f40 100644
--- a/astroid/arguments.py
+++ b/astroid/arguments.py
@@ -183,6 +183,16 @@ class CallSite(object):
else:
# XXX can do better ?
boundnode = funcnode.parent.frame()
+
+ if isinstance(boundnode, nodes.ClassDef):
+ # Verify that we're accessing a method
+ # of the metaclass through a class, as in
+ # `cls.metaclass_method`. In this case, the
+ # first argument is always the class.
+ method_scope = funcnode.parent.scope()
+ if method_scope is boundnode.metaclass():
+ return iter((boundnode, ))
+
if funcnode.type == 'method':
if not isinstance(boundnode, bases.Instance):
boundnode = bases.Instance(boundnode)