From a0b4e76c1a1d05da0ef93bf4fb726aa404ae10f8 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 8 Jul 2019 17:03:45 -0700 Subject: [PATCH] Fix some *args issues --- jedi/api/helpers.py | 14 +++++++------- test/test_api/test_call_signatures.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 7054c225..916ad3ce 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -185,17 +185,17 @@ class CallDetails(object): else: return None - print(args) is_kwarg = False for i, (star_count, key_start, had_equal) in enumerate(args): is_kwarg |= had_equal | (star_count == 2) if star_count: 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: - 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): kind = param_name.get_kind() @@ -204,14 +204,14 @@ class CallDetails(object): if kind == Parameter.VAR_POSITIONAL: return i if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.POSITIONAL_ONLY): - if i + 1 == positional_count: + if i == positional_count: return i if key_start is not None: if param_name.string_name not in used_names \ and (kind == Parameter.KEYWORD_ONLY or kind == Parameter.POSITIONAL_OR_KEYWORD - and positional_count < i + 1): + and positional_count <= i): if had_equal: if param_name.string_name == key_start: return i diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 1e50b9a7..0111af00 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -451,8 +451,8 @@ code4 = 'def i(u, /, v, *args, x=1, y, **kwargs): pass' (code3, 'h(a,b,args=', None), (code3, 'h(u,v=', 1), (code3, 'h(u=', None), - #(code3, 'h(u,*xxx', 1), - #(code3, 'h(u,*[]', 1), + (code3, 'h(u,*xxx', 1), + (code3, 'h(u,*[]', 1), # *args, **kwargs (code4, 'i(a,b,c,d', 2),