mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Don't return multiple used names for signatures
This commit is contained in:
@@ -121,8 +121,9 @@ def process_params(param_names, star_count=3): # default means both * and **
|
||||
if star_count == 1:
|
||||
yield ParamNameFixedKind(p, Parameter.POSITIONAL_ONLY)
|
||||
elif star_count == 2:
|
||||
yield ParamNameFixedKind(p, Parameter.KEYWORD_ONLY)
|
||||
kw_only_params.append(ParamNameFixedKind(p, Parameter.KEYWORD_ONLY))
|
||||
else:
|
||||
used_names.add(p.string_name)
|
||||
yield p
|
||||
|
||||
for func_and_argument in arg_funcs:
|
||||
@@ -152,10 +153,15 @@ def process_params(param_names, star_count=3): # default means both * and **
|
||||
if star_count == 1 and p.get_kind() != Parameter.VAR_POSITIONAL:
|
||||
yield ParamNameFixedKind(p, Parameter.POSITIONAL_ONLY)
|
||||
else:
|
||||
if p.get_kind() == Parameter.POSITIONAL_OR_KEYWORD:
|
||||
used_names.add(p.string_name)
|
||||
yield p
|
||||
|
||||
for p in kw_only_params:
|
||||
if p.string_name in used_names:
|
||||
continue
|
||||
yield p
|
||||
used_names.add(p.string_name)
|
||||
|
||||
for func, arguments in kwarg_funcs:
|
||||
for p in process_params(
|
||||
@@ -168,7 +174,6 @@ def process_params(param_names, star_count=3): # default means both * and **
|
||||
|
||||
if kwarg_names:
|
||||
yield kwarg_names[0]
|
||||
return
|
||||
|
||||
|
||||
class ParamNameFixedKind(ParamNameWrapper):
|
||||
@@ -178,4 +183,3 @@ class ParamNameFixedKind(ParamNameWrapper):
|
||||
|
||||
def get_kind(self):
|
||||
return self._new_kind
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ def test_tree_signature(Script, environment, code, expected):
|
||||
'combination, expected', [
|
||||
('full_redirect(simple)', 'b, *, c'),
|
||||
|
||||
('two_redirects(simple, simple)', 'a, b, *, c'),
|
||||
|
||||
('combined_redirect(simple, simple2)', 'a, b, /, *, x'),
|
||||
('combined_redirect(simple, simple3)', 'a, b, /, *, a, x: int'),
|
||||
('combined_redirect(simple2, simple)', 'x, /, *, a, b, c'),
|
||||
@@ -134,6 +136,8 @@ def test_nested_signatures(Script, environment, combination, expected):
|
||||
return lambda *args, **kwargs: func(1)
|
||||
def full_redirect(func):
|
||||
return lambda *args, **kwargs: func(1, *args, **kwargs)
|
||||
def two_redirects(func1, func2):
|
||||
return lambda *args, **kwargs: func1(*args, **kwargs) + func2(1, *args, **kwargs)
|
||||
def combined_redirect(func1, func2):
|
||||
return lambda *args, **kwargs: func1(*args) + func2(**kwargs)
|
||||
def combined_lot_of_args(func1, func2):
|
||||
|
||||
Reference in New Issue
Block a user