diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 6f4f2627..297329af 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -363,6 +363,10 @@ class BaseDefinition(object): for signature in context.get_signatures(): return [Definition(self._evaluator, n) for n in signature.get_param_names()] + if self.type == 'function' or self.type == 'class': + # Fallback, if no signatures were defined (which is probably by + # itself a bug). + return [] raise AttributeError('There are no params defined on this.') def parent(self): diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index e2148018..b0cf2432 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -174,6 +174,12 @@ def test_completion_params(Script): assert [p.name for p in c.params] == ['s', 'sep'] +def test_functions_should_have_params(Script): + for c in Script('bool.').completions(): + if c.type == 'function': + assert isinstance(c.params, list) + + def test_hashlib_params(Script, environment): if environment.version_info < (3,): pytest.skip()