forked from VimPlug/jedi
Call signatures should work better for builtin classes (ducktyping). Fixes #515.
This commit is contained in:
@@ -275,11 +275,16 @@ def get_instance_el(evaluator, instance, var, is_class_var=False):
|
||||
"""
|
||||
Returns an InstanceElement if it makes sense, otherwise leaves the object
|
||||
untouched.
|
||||
|
||||
Basically having an InstanceElement is context information. That is needed
|
||||
in quite a lot of cases, which includes Nodes like ``power``, that need to
|
||||
know where a self name comes from for example.
|
||||
"""
|
||||
if isinstance(var, pr.Name):
|
||||
parent = get_instance_el(evaluator, instance, var.parent, is_class_var)
|
||||
return InstanceName(var, parent)
|
||||
elif isinstance(var, (Instance, compiled.CompiledObject, pr.Leaf,
|
||||
elif var.type != 'funcdef' \
|
||||
and isinstance(var, (Instance, compiled.CompiledObject, pr.Leaf,
|
||||
pr.Module, FunctionExecution)):
|
||||
return var
|
||||
|
||||
@@ -364,6 +369,11 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)):
|
||||
return self.var.is_scope()
|
||||
|
||||
def py__call__(self, evaluator, params):
|
||||
if isinstance(self.var, compiled.CompiledObject):
|
||||
# This check is a bit strange, but CompiledObject itself is a bit
|
||||
# more complicated than we would it actually like to be.
|
||||
return self.var.py__call__(evaluator, params)
|
||||
else:
|
||||
return Function.py__call__(self, evaluator, params)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -238,7 +238,7 @@ class TestParams(TestCase):
|
||||
p = self.params('str.endswith(')
|
||||
assert p[0].name == 'self'
|
||||
assert p[1].name == 'suffix'
|
||||
p = self.params('str.endswith(')
|
||||
p = self.params('str().endswith(')
|
||||
assert p[0].name == 'suffix'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user