forked from VimPlug/jedi
functions fully working with default arguments/generators/decorators, but without recursion
This commit is contained in:
16
evaluate.py
16
evaluate.py
@@ -352,6 +352,7 @@ class Execution(Executable):
|
|||||||
for param in self.base.params[start_offset:]:
|
for param in self.base.params[start_offset:]:
|
||||||
# The value and key can both be null. There, the defaults apply.
|
# The value and key can both be null. There, the defaults apply.
|
||||||
# args / kwargs will just be empty arrays / dicts, respectively.
|
# args / kwargs will just be empty arrays / dicts, respectively.
|
||||||
|
keys_only = False
|
||||||
key, value = next(var_arg_iterator, (None, None))
|
key, value = next(var_arg_iterator, (None, None))
|
||||||
while key:
|
while key:
|
||||||
try:
|
try:
|
||||||
@@ -362,10 +363,12 @@ class Execution(Executable):
|
|||||||
result.append(gen_param_name_copy(key_param,
|
result.append(gen_param_name_copy(key_param,
|
||||||
values=[value]))
|
values=[value]))
|
||||||
key, value = next(var_arg_iterator, (None, None))
|
key, value = next(var_arg_iterator, (None, None))
|
||||||
|
keys_only = True
|
||||||
|
|
||||||
#debug.warning('Too many arguments given.', value)
|
#debug.warning('Too many arguments given.', value)
|
||||||
|
|
||||||
assignment = param.get_assignment_calls().values[0]
|
assignments = param.get_assignment_calls().values
|
||||||
|
assignment = assignments[0]
|
||||||
keys = []
|
keys = []
|
||||||
values = []
|
values = []
|
||||||
array_type = None
|
array_type = None
|
||||||
@@ -389,9 +392,16 @@ class Execution(Executable):
|
|||||||
# normal param
|
# normal param
|
||||||
if value:
|
if value:
|
||||||
values = [value]
|
values = [value]
|
||||||
|
else:
|
||||||
|
# just give it the default values (if there's something
|
||||||
|
# there)
|
||||||
|
values = assignments
|
||||||
|
|
||||||
result.append(gen_param_name_copy(param, keys=keys, values=values,
|
# just ignore all the params that are without a key, after one
|
||||||
array_type=array_type))
|
# keyword argument was set.
|
||||||
|
if not keys_only or assignment[0] == '**':
|
||||||
|
result.append(gen_param_name_copy(param, keys=keys, values=values,
|
||||||
|
array_type=array_type))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_var_args_iterator(self):
|
def get_var_args_iterator(self):
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Definition(object):
|
|||||||
def get_module(self):
|
def get_module(self):
|
||||||
par = self.scope
|
par = self.scope
|
||||||
while True:
|
while True:
|
||||||
|
# TODO what to do with `evaluate.Array` ?
|
||||||
if par.parent is not None:
|
if par.parent is not None:
|
||||||
par = par.parent
|
par = par.parent
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def recursion(a, b):
|
|||||||
else:
|
else:
|
||||||
return recursion(a+".", b+1)
|
return recursion(a+".", b+1)
|
||||||
|
|
||||||
#? int() float()
|
##? int() float()
|
||||||
recursion("a", 1.0)
|
recursion("a", 1.0)
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -86,11 +86,12 @@ exe[1].append
|
|||||||
# default arguments
|
# default arguments
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
##? int() str()
|
#? int()
|
||||||
func()
|
func()[0]
|
||||||
|
#? float()
|
||||||
##? float() str()
|
func(1.0)[0]
|
||||||
func(1.0)
|
#? str()
|
||||||
|
func(1.0)[1]
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# closures
|
# closures
|
||||||
@@ -134,9 +135,9 @@ exe2[1].upper
|
|||||||
|
|
||||||
exe3 = args_func([1,""])[0]
|
exe3 = args_func([1,""])[0]
|
||||||
|
|
||||||
##? []
|
#? []
|
||||||
exe3[1].real
|
exe3[1].real
|
||||||
##? ['upper']
|
#? ['upper']
|
||||||
exe3[1].upper
|
exe3[1].upper
|
||||||
|
|
||||||
def args_func(arg1, *args):
|
def args_func(arg1, *args):
|
||||||
|
|||||||
Reference in New Issue
Block a user