staticmethod and a few other cases might not have properly returned its signatures

This commit is contained in:
Dave Halter
2019-08-12 09:37:59 +02:00
parent 972cae4859
commit 5d0d09bb7d
2 changed files with 10 additions and 3 deletions

View File

@@ -137,8 +137,10 @@ class ClassMixin(object):
def is_class(self): def is_class(self):
return True return True
def py__call__(self, arguments): def py__call__(self, arguments=None):
from jedi.evaluate.context import TreeInstance from jedi.evaluate.context import TreeInstance
if arguments is None:
arguments = ValuesArguments([])
return ContextSet([TreeInstance(self.evaluator, self.parent_context, self, arguments)]) return ContextSet([TreeInstance(self.evaluator, self.parent_context, self, arguments)])
def py__class__(self): def py__class__(self):
@@ -215,7 +217,7 @@ class ClassMixin(object):
type_ = builtin_from_name(self.evaluator, u'type') type_ = builtin_from_name(self.evaluator, u'type')
assert isinstance(type_, ClassContext) assert isinstance(type_, ClassContext)
if type_ != self: if type_ != self:
for instance in type_.py__call__(ValuesArguments([])): for instance in type_.py__call__():
instance_filters = instance.get_filters() instance_filters = instance.get_filters()
# Filter out self filters # Filter out self filters
next(instance_filters) next(instance_filters)
@@ -223,7 +225,7 @@ class ClassMixin(object):
yield next(instance_filters) yield next(instance_filters)
def get_signatures(self): def get_signatures(self):
init_funcs = self.execute_evaluated().py__getattribute__('__init__') init_funcs = self.py__call__().py__getattribute__('__init__')
return [sig.bind(self) for sig in init_funcs.get_signatures()] return [sig.bind(self) for sig in init_funcs.get_signatures()]
def get_global_filter(self, until_position=None, origin_scope=None): def get_global_filter(self, until_position=None, origin_scope=None):

View File

@@ -67,3 +67,8 @@ def test_param_kind_and_name(code, index, param_code, kind, Script, skip_python2
param = sig.params[index] param = sig.params[index]
assert param.to_string() == param_code assert param.to_string() == param_code
assert param.kind.name == kind assert param.kind.name == kind
def test_staticmethod(Script):
s, = Script('staticmethod(').call_signatures()
assert s.to_string() == 'staticmethod(f: Callable)'