mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
fix a default argument issue
This commit is contained in:
@@ -170,10 +170,11 @@ def get_params(evaluator, func, var_args):
|
|||||||
# about the values inside, it's about the names. Jedi needs to now that
|
# about the values inside, it's about the names. Jedi needs to now that
|
||||||
# there's nothing to find for certain names.
|
# there's nothing to find for certain names.
|
||||||
for k in set(param_dict) - keys_used:
|
for k in set(param_dict) - keys_used:
|
||||||
result.append(_gen_param_name_copy(func, var_args, param_dict[k]))
|
param = param_dict[k]
|
||||||
|
result.append(_gen_param_name_copy(func, var_args, param))
|
||||||
|
|
||||||
if not (non_matching_keys or had_multiple_value_error
|
if not (non_matching_keys or had_multiple_value_error
|
||||||
or param_dict[k].stars):
|
or param.stars or param.assignment_details):
|
||||||
# add a warning only if there's not another one.
|
# add a warning only if there's not another one.
|
||||||
calling_va = _get_calling_var_args(evaluator, var_args)
|
calling_va = _get_calling_var_args(evaluator, var_args)
|
||||||
if calling_va is not None:
|
if calling_va is not None:
|
||||||
|
|||||||
@@ -38,3 +38,20 @@ two_params(1, y=2)
|
|||||||
two_params(1, x=2)
|
two_params(1, x=2)
|
||||||
#! 17 type-error-too-many-arguments
|
#! 17 type-error-too-many-arguments
|
||||||
two_params(1, 2, y=3)
|
two_params(1, 2, y=3)
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# default arguments
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
def default(x, y=1, z=2):
|
||||||
|
return x
|
||||||
|
|
||||||
|
#! 7 type-error-too-few-arguments
|
||||||
|
default()
|
||||||
|
default(1)
|
||||||
|
default(1, 2)
|
||||||
|
default(1, 2, 3)
|
||||||
|
#! 17 type-error-too-many-arguments
|
||||||
|
default(1, 2, 3, 4)
|
||||||
|
|
||||||
|
default(x=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user