Fix some *args issues

This commit is contained in:
Dave Halter
2019-07-08 17:03:45 -07:00
parent 97bf83aa03
commit a0b4e76c1a
2 changed files with 9 additions and 9 deletions

View File

@@ -185,14 +185,14 @@ 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: else:
if i + 1 != len(args): if i + 1 != len(args): # Not last
if had_equal:
used_names.add(key_start) used_names.add(key_start)
else: else:
positional_count += 1 positional_count += 1
@@ -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

View File

@@ -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),