forked from VimPlug/jedi
Fix some issues for args resolving in method calls
This commit is contained in:
@@ -400,7 +400,7 @@ class BoundMethod(FunctionMixin, ContextWrapper):
|
|||||||
return function_execution.infer()
|
return function_execution.infer()
|
||||||
|
|
||||||
def get_signatures(self):
|
def get_signatures(self):
|
||||||
return [sig.bind(self) for sig in self._wrapped_context.get_signatures()]
|
return [sig.bind(self) for sig in super(BoundMethod, self).get_signatures()]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: %s>' % (self.__class__.__name__, self._wrapped_context)
|
return '<%s: %s>' % (self.__class__.__name__, self._wrapped_context)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from operator import ge, lt
|
from operator import ge, lt
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -103,11 +104,16 @@ def test_tree_signature(Script, environment, code, expected):
|
|||||||
|
|
||||||
# Non functions
|
# Non functions
|
||||||
('full_redirect(lambda x, y: ...)', 'y'),
|
('full_redirect(lambda x, y: ...)', 'y'),
|
||||||
('full_redirect(C)', 'z, *c'),
|
|
||||||
('full_redirect(C())', 'y'),
|
|
||||||
('full_redirect()', '*args, **kwargs'),
|
('full_redirect()', '*args, **kwargs'),
|
||||||
('full_redirect(1)', '*args, **kwargs'),
|
('full_redirect(1)', '*args, **kwargs'),
|
||||||
|
|
||||||
|
# Classes / inheritance
|
||||||
|
('full_redirect(C)', 'z, *c'),
|
||||||
|
('full_redirect(C())', 'y'),
|
||||||
|
('D', 'D(x, ly)'),
|
||||||
|
('D()', 'D(x, y)'),
|
||||||
|
('D().foo', 'foo(a, *, bar, z, **kwargs)'),
|
||||||
|
|
||||||
# Merging
|
# Merging
|
||||||
('two_redirects(simple, simple)', 'a, b, *, c'),
|
('two_redirects(simple, simple)', 'a, b, *, c'),
|
||||||
('two_redirects(simple2, simple2)', 'x'),
|
('two_redirects(simple2, simple2)', 'x'),
|
||||||
@@ -162,11 +168,22 @@ def test_nested_signatures(Script, environment, combination, expected, skip_pre_
|
|||||||
class C:
|
class C:
|
||||||
def __init__(self, a, z, *c): ...
|
def __init__(self, a, z, *c): ...
|
||||||
def __call__(self, x, y): ...
|
def __call__(self, x, y): ...
|
||||||
|
|
||||||
|
def foo(self, bar, z, **kwargs): ...
|
||||||
|
|
||||||
|
class D(C):
|
||||||
|
def __init__(self, *args):
|
||||||
|
super().foo(*args)
|
||||||
|
|
||||||
|
def foo(self, a, **kwargs):
|
||||||
|
super().foo(**kwargs)
|
||||||
''')
|
''')
|
||||||
code += 'z = ' + combination + '\nz('
|
code += 'z = ' + combination + '\nz('
|
||||||
sig, = Script(code).call_signatures()
|
sig, = Script(code).call_signatures()
|
||||||
computed = sig._signature.to_string()
|
computed = sig._signature.to_string()
|
||||||
assert '<lambda>(' + expected + ')' == computed
|
if not re.match('\w+\(', expected):
|
||||||
|
expected = '<lambda>(' + expected + ')'
|
||||||
|
assert expected == computed
|
||||||
|
|
||||||
|
|
||||||
def test_pow_signature(Script):
|
def test_pow_signature(Script):
|
||||||
|
|||||||
Reference in New Issue
Block a user