mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix some *args issues
This commit is contained in:
@@ -185,17 +185,17 @@ class CallDetails(object):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print(args)
|
|
||||||
is_kwarg = False
|
is_kwarg = False
|
||||||
for i, (star_count, key_start, had_equal) in enumerate(args):
|
for i, (star_count, key_start, had_equal) in enumerate(args):
|
||||||
is_kwarg |= had_equal | (star_count == 2)
|
is_kwarg |= had_equal | (star_count == 2)
|
||||||
if star_count:
|
if star_count:
|
||||||
pass # For now do nothing, we don't know what's in there here.
|
pass # For now do nothing, we don't know what's in there here.
|
||||||
elif had_equal:
|
|
||||||
if i + 1 != len(args):
|
|
||||||
used_names.add(key_start)
|
|
||||||
else:
|
else:
|
||||||
positional_count += 1
|
if i + 1 != len(args): # Not last
|
||||||
|
if had_equal:
|
||||||
|
used_names.add(key_start)
|
||||||
|
else:
|
||||||
|
positional_count += 1
|
||||||
|
|
||||||
for i, param_name in enumerate(param_names):
|
for i, param_name in enumerate(param_names):
|
||||||
kind = param_name.get_kind()
|
kind = param_name.get_kind()
|
||||||
@@ -204,14 +204,14 @@ class CallDetails(object):
|
|||||||
if kind == Parameter.VAR_POSITIONAL:
|
if kind == Parameter.VAR_POSITIONAL:
|
||||||
return i
|
return i
|
||||||
if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.POSITIONAL_ONLY):
|
if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.POSITIONAL_ONLY):
|
||||||
if i + 1 == positional_count:
|
if i == positional_count:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
if key_start is not None:
|
if key_start is not None:
|
||||||
if param_name.string_name not in used_names \
|
if param_name.string_name not in used_names \
|
||||||
and (kind == Parameter.KEYWORD_ONLY
|
and (kind == Parameter.KEYWORD_ONLY
|
||||||
or kind == Parameter.POSITIONAL_OR_KEYWORD
|
or kind == Parameter.POSITIONAL_OR_KEYWORD
|
||||||
and positional_count < i + 1):
|
and positional_count <= i):
|
||||||
if had_equal:
|
if had_equal:
|
||||||
if param_name.string_name == key_start:
|
if param_name.string_name == key_start:
|
||||||
return i
|
return i
|
||||||
|
|||||||
@@ -451,8 +451,8 @@ code4 = 'def i(u, /, v, *args, x=1, y, **kwargs): pass'
|
|||||||
(code3, 'h(a,b,args=', None),
|
(code3, 'h(a,b,args=', None),
|
||||||
(code3, 'h(u,v=', 1),
|
(code3, 'h(u,v=', 1),
|
||||||
(code3, 'h(u=', None),
|
(code3, 'h(u=', None),
|
||||||
#(code3, 'h(u,*xxx', 1),
|
(code3, 'h(u,*xxx', 1),
|
||||||
#(code3, 'h(u,*[]', 1),
|
(code3, 'h(u,*[]', 1),
|
||||||
|
|
||||||
# *args, **kwargs
|
# *args, **kwargs
|
||||||
(code4, 'i(a,b,c,d', 2),
|
(code4, 'i(a,b,c,d', 2),
|
||||||
|
|||||||
Reference in New Issue
Block a user