forked from VimPlug/jedi
Test and preparations for better call signatures with builtins, see #515.
This commit is contained in:
@@ -326,7 +326,7 @@ class BaseDefinition(object):
|
|||||||
raise AttributeError()
|
raise AttributeError()
|
||||||
followed = followed[0] # only check the first one.
|
followed = followed[0] # only check the first one.
|
||||||
|
|
||||||
if followed.isinstance(er.Function):
|
if followed.type == 'funcdef':
|
||||||
if isinstance(followed, er.InstanceElement):
|
if isinstance(followed, er.InstanceElement):
|
||||||
params = followed.params[1:]
|
params = followed.params[1:]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ class CompiledObject(Base):
|
|||||||
def params(self):
|
def params(self):
|
||||||
params_str, ret = self._parse_function_doc()
|
params_str, ret = self._parse_function_doc()
|
||||||
tokens = params_str.split(',')
|
tokens = params_str.split(',')
|
||||||
|
if inspect.ismethoddescriptor(self._cls().obj):
|
||||||
|
tokens.insert(0, 'self')
|
||||||
params = []
|
params = []
|
||||||
for p in tokens:
|
for p in tokens:
|
||||||
parts = [FakeName(part) for part in p.strip().split('=')]
|
parts = [FakeName(part) for part in p.strip().split('=')]
|
||||||
|
|||||||
@@ -230,6 +230,18 @@ class TestParams(TestCase):
|
|||||||
assert p[0].name in ['file', 'name']
|
assert p[0].name in ['file', 'name']
|
||||||
assert p[1].name == 'mode'
|
assert p[1].name == 'mode'
|
||||||
|
|
||||||
|
def test_builtins(self):
|
||||||
|
"""
|
||||||
|
The self keyword should be visible even for builtins, if not
|
||||||
|
instantiated.
|
||||||
|
"""
|
||||||
|
p = self.params('str.endswith(')
|
||||||
|
assert p[0].name == 'self'
|
||||||
|
assert p[1].name == 'suffix'
|
||||||
|
p = self.params('str.endswith(')
|
||||||
|
assert p[0].name == 'suffix'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_signature_is_definition():
|
def test_signature_is_definition():
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user