forked from VimPlug/jedi
some param refactorings.
This commit is contained in:
@@ -46,11 +46,10 @@ def get_params(evaluator, func, var_args):
|
|||||||
values=[value]))
|
values=[value]))
|
||||||
key, value = next(var_arg_iterator, (None, None))
|
key, value = next(var_arg_iterator, (None, None))
|
||||||
|
|
||||||
expression_list = param.expression_list()
|
|
||||||
keys = []
|
keys = []
|
||||||
values = []
|
values = []
|
||||||
array_type = None
|
array_type = None
|
||||||
ignore_creation = False
|
has_default_value = False
|
||||||
if param.stars == 1:
|
if param.stars == 1:
|
||||||
# *args param
|
# *args param
|
||||||
array_type = pr.Array.TUPLE
|
array_type = pr.Array.TUPLE
|
||||||
@@ -75,7 +74,7 @@ def get_params(evaluator, func, var_args):
|
|||||||
else:
|
else:
|
||||||
if param.assignment_details:
|
if param.assignment_details:
|
||||||
# No value: return the default values.
|
# No value: return the default values.
|
||||||
ignore_creation = True
|
has_default_value = True
|
||||||
result.append(param.get_name())
|
result.append(param.get_name())
|
||||||
param.is_generated = True
|
param.is_generated = True
|
||||||
else:
|
else:
|
||||||
@@ -94,14 +93,14 @@ def get_params(evaluator, func, var_args):
|
|||||||
|
|
||||||
# Just ignore all the params that are without a key, after one keyword
|
# Just ignore all the params that are without a key, after one keyword
|
||||||
# argument was set.
|
# argument was set.
|
||||||
if not ignore_creation and (not keys_only or expression_list[0] == '**'):
|
if not has_default_value and (not keys_only or param.stars == 2):
|
||||||
keys_used.add(str(key))
|
keys_used.add(str(key))
|
||||||
result.append(_gen_param_name_copy(func, var_args, param,
|
result.append(_gen_param_name_copy(func, var_args, param,
|
||||||
keys=keys, values=values,
|
keys=keys, values=values,
|
||||||
array_type=array_type))
|
array_type=array_type))
|
||||||
|
|
||||||
if keys_only:
|
if keys_only:
|
||||||
# sometimes param arguments are not completely written (which would
|
# Sometimes param arguments are not completely written (which would
|
||||||
# create an Exception, but we have to handle that).
|
# create an Exception, but we have to handle that).
|
||||||
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]))
|
result.append(_gen_param_name_copy(func, var_args, param_dict[k]))
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ simple(b=1)
|
|||||||
simple(1, a=1)
|
simple(1, a=1)
|
||||||
|
|
||||||
|
|
||||||
def two_params(a, b):
|
def two_params(x, y):
|
||||||
return b
|
return y
|
||||||
|
|
||||||
two_params(b=2, a=1)
|
two_params(y=2, x=1)
|
||||||
two_params(1, b=2)
|
two_params(1, y=2)
|
||||||
#! 10 type-error
|
#! 10 type-error
|
||||||
two_params(1, a=2)
|
two_params(1, x=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user