diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 273433e2..111f75b4 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -280,7 +280,7 @@ class CallDetails: def count_positional_arguments(self): count = 0 for star_count, key_start, had_equal in self._list_arguments()[:-1]: - if star_count: + if star_count or key_start: break count += 1 return count diff --git a/test/test_api/test_interpreter.py b/test/test_api/test_interpreter.py index 131ec6c1..848bca74 100644 --- a/test/test_api/test_interpreter.py +++ b/test/test_api/test_interpreter.py @@ -739,3 +739,18 @@ def test_param_infer_default(): param, = abs_sig.params assert param.name == 'x' assert param.infer_default() == [] + + +@pytest.mark.parametrize( + 'code, expected', [ + ("random.triangular(", ['high=', 'low=', 'mode=']), + ("random.triangular(low=1, ", ['high=', 'mode=']), + ("random.triangular(high=1, ", ['low=', 'mode=']), + ("random.triangular(low=1, high=2, ", ['mode=']), + ("random.triangular(low=1, mode=2, ", ['high=']), + ], +) +def test_keyword_param_completion(code, expected): + import random + completions = jedi.Interpreter(code, [locals()]).complete() + assert expected == [c.name for c in completions if c.name.endswith('=')]