mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix classmethod signature, fixes #498
This commit is contained in:
@@ -381,6 +381,9 @@ class ClassMethodGet(AttributeOverwrite, ContextWrapper):
|
|||||||
self._class = klass
|
self._class = klass
|
||||||
self._function = function
|
self._function = function
|
||||||
|
|
||||||
|
def get_signatures(self):
|
||||||
|
return self._function.get_signatures()
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self._wrapped_context
|
return self._wrapped_context
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ def test_compiled_signature(Script, environment, code, sig, names, op, version):
|
|||||||
assert [n.string_name for n in signature.get_param_names()] == names
|
assert [n.string_name for n in signature.get_param_names()] == names
|
||||||
|
|
||||||
|
|
||||||
|
class_method_code = '''
|
||||||
|
class X:
|
||||||
|
@classmethod
|
||||||
|
def x(cls, a, b):
|
||||||
|
pass
|
||||||
|
'''
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'code, expected', [
|
'code, expected', [
|
||||||
('def f(a, * args, x): pass\n f(', 'f(a, *args, x)'),
|
('def f(a, * args, x): pass\n f(', 'f(a, *args, x)'),
|
||||||
@@ -43,6 +50,9 @@ def test_compiled_signature(Script, environment, code, sig, names, op, version):
|
|||||||
('def f(*, x= 3,**kwargs): pass\n f(', 'f(*, x=3, **kwargs)'),
|
('def f(*, x= 3,**kwargs): pass\n f(', 'f(*, x=3, **kwargs)'),
|
||||||
('def f(x,/,y,* ,z): pass\n f(', 'f(x, /, y, *, z)'),
|
('def f(x,/,y,* ,z): pass\n f(', 'f(x, /, y, *, z)'),
|
||||||
('def f(a, /, *, x=3, **kwargs): pass\n f(', 'f(a, /, *, x=3, **kwargs)'),
|
('def f(a, /, *, x=3, **kwargs): pass\n f(', 'f(a, /, *, x=3, **kwargs)'),
|
||||||
|
|
||||||
|
(class_method_code + 'X.x(', 'x(cls, a, b)'),
|
||||||
|
(class_method_code + 'X().x(', 'x(cls, a, b)'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_tree_signature(Script, environment, code, expected):
|
def test_tree_signature(Script, environment, code, expected):
|
||||||
|
|||||||
Reference in New Issue
Block a user