mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix keyword argument completion, fixes #1856
This commit is contained in:
@@ -280,7 +280,7 @@ class CallDetails:
|
|||||||
def count_positional_arguments(self):
|
def count_positional_arguments(self):
|
||||||
count = 0
|
count = 0
|
||||||
for star_count, key_start, had_equal in self._list_arguments()[:-1]:
|
for star_count, key_start, had_equal in self._list_arguments()[:-1]:
|
||||||
if star_count:
|
if star_count or key_start:
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|||||||
@@ -739,3 +739,18 @@ def test_param_infer_default():
|
|||||||
param, = abs_sig.params
|
param, = abs_sig.params
|
||||||
assert param.name == 'x'
|
assert param.name == 'x'
|
||||||
assert param.infer_default() == []
|
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('=')]
|
||||||
|
|||||||
Reference in New Issue
Block a user