forked from VimPlug/jedi
nested functions with *args should only raise an error if there's well defined input.
This commit is contained in:
@@ -48,6 +48,10 @@ def _get_calling_var_args(evaluator, var_args):
|
|||||||
break
|
break
|
||||||
param = names[0].parent
|
param = names[0].parent
|
||||||
if not isinstance(param, ExecutedParam):
|
if not isinstance(param, ExecutedParam):
|
||||||
|
if isinstance(param, pr.Param):
|
||||||
|
# There is no calling var_args in this case - there's just
|
||||||
|
# a param without any input.
|
||||||
|
return None
|
||||||
break
|
break
|
||||||
# We never want var_args to be a tuple. This should be enough for
|
# We never want var_args to be a tuple. This should be enough for
|
||||||
# now, we can change it later, if we need to.
|
# now, we can change it later, if we need to.
|
||||||
@@ -139,9 +143,10 @@ def get_params(evaluator, func, var_args):
|
|||||||
values = []
|
values = []
|
||||||
if not keys_only and isinstance(var_args, pr.Array):
|
if not keys_only and isinstance(var_args, pr.Array):
|
||||||
calling_va = _get_calling_var_args(evaluator, var_args)
|
calling_va = _get_calling_var_args(evaluator, var_args)
|
||||||
m = _error_argument_count(func, len(var_args))
|
if calling_va is not None:
|
||||||
analysis.add(evaluator, 'type-error-too-few-arguments',
|
m = _error_argument_count(func, len(var_args))
|
||||||
calling_va, message=m)
|
analysis.add(evaluator, 'type-error-too-few-arguments',
|
||||||
|
calling_va, message=m)
|
||||||
else:
|
else:
|
||||||
values = [value]
|
values = [value]
|
||||||
|
|
||||||
@@ -194,7 +199,6 @@ def _var_args_iterator(evaluator, var_args):
|
|||||||
# *args must be some sort of an array, otherwise -> ignore
|
# *args must be some sort of an array, otherwise -> ignore
|
||||||
for array in evaluator.eval_expression_list(expression_list[1:]):
|
for array in evaluator.eval_expression_list(expression_list[1:]):
|
||||||
if isinstance(array, iterable.Array):
|
if isinstance(array, iterable.Array):
|
||||||
#print('star', array, id(array))
|
|
||||||
for field_stmt in array: # yield from plz!
|
for field_stmt in array: # yield from plz!
|
||||||
yield None, field_stmt
|
yield None, field_stmt
|
||||||
elif isinstance(array, iterable.Generator):
|
elif isinstance(array, iterable.Generator):
|
||||||
|
|||||||
@@ -2,9 +2,14 @@
|
|||||||
def simple(a):
|
def simple(a):
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
|
||||||
def nested(*args):
|
def nested(*args):
|
||||||
return simple(*args)
|
return simple(*args)
|
||||||
|
|
||||||
nested(1)
|
nested(1)
|
||||||
#! 6 type-error-too-few-arguments
|
#! 6 type-error-too-few-arguments
|
||||||
nested()
|
nested()
|
||||||
|
|
||||||
|
|
||||||
|
def nested_no_call_to_function(*args):
|
||||||
|
return simple(1, *args)
|
||||||
|
|||||||
Reference in New Issue
Block a user