mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-27 18:52:18 +08:00
param keys of dicts are statements now
This commit is contained in:
@@ -509,23 +509,19 @@ class Execution(Executable):
|
|||||||
if parent is not None:
|
if parent is not None:
|
||||||
new_param.parent = parent
|
new_param.parent = parent
|
||||||
|
|
||||||
if array_type is not None:
|
# create an Array (-> needed for *args/**kwargs tuples/dicts)
|
||||||
# create an Array (-> needed for *args/**kwargs tuples/dicts)
|
arr = pr.Array(self.module, start_pos, array_type, parent)
|
||||||
arr = pr.Array(self.module, start_pos, array_type, parent)
|
arr.values = values
|
||||||
"""
|
key_stmts = []
|
||||||
for i, value in enumerate(values): # TODO delete?
|
for key in keys:
|
||||||
try:
|
stmt = pr.Statement(self.module, 'XXX code', [], [], [], [],
|
||||||
keys[i]
|
start_pos, None)
|
||||||
except IndexError:
|
stmt._commands = [key]
|
||||||
pass
|
key_stmts.append(stmt)
|
||||||
"""
|
arr.keys = key_stmts
|
||||||
arr.values = values
|
arr.type = array_type
|
||||||
arr.keys = keys
|
|
||||||
arr.type = array_type
|
|
||||||
|
|
||||||
new_param._commands = [arr]
|
new_param._commands = [arr]
|
||||||
else:
|
|
||||||
new_param._commands = values
|
|
||||||
|
|
||||||
name = copy.copy(param.get_name())
|
name = copy.copy(param.get_name())
|
||||||
name.parent = new_param
|
name.parent = new_param
|
||||||
@@ -573,6 +569,7 @@ class Execution(Executable):
|
|||||||
keys = []
|
keys = []
|
||||||
values = []
|
values = []
|
||||||
array_type = None
|
array_type = None
|
||||||
|
ignore_creation = False
|
||||||
if commands[0] == '*':
|
if commands[0] == '*':
|
||||||
# *args param
|
# *args param
|
||||||
array_type = pr.Array.TUPLE
|
array_type = pr.Array.TUPLE
|
||||||
@@ -591,12 +588,14 @@ class Execution(Executable):
|
|||||||
keys, values = zip(*non_matching_keys)
|
keys, values = zip(*non_matching_keys)
|
||||||
else:
|
else:
|
||||||
# normal param
|
# normal param
|
||||||
if value:
|
if value is not None:
|
||||||
values = [value]
|
values = [value]
|
||||||
else:
|
else:
|
||||||
if param.assignment_details:
|
if param.assignment_details:
|
||||||
# No value: return the default values.
|
# No value: return the default values.
|
||||||
values = commands
|
ignore_creation = True
|
||||||
|
result.append(param.get_name())
|
||||||
|
param.is_generated=True
|
||||||
else:
|
else:
|
||||||
# If there is no assignment detail, that means there is
|
# If there is no assignment detail, that means there is
|
||||||
# no assignment, just the result. Therefore nothing has
|
# no assignment, just the result. Therefore nothing has
|
||||||
@@ -605,7 +604,7 @@ class Execution(Executable):
|
|||||||
|
|
||||||
# Just ignore all the params that are without a key, after one
|
# Just ignore all the params that are without a key, after one
|
||||||
# keyword argument was set.
|
# keyword argument was set.
|
||||||
if not keys_only or commands[0] == '**':
|
if not ignore_creation and (not keys_only or commands[0] == '**'):
|
||||||
keys_used.add(str(key))
|
keys_used.add(str(key))
|
||||||
result.append(gen_param_name_copy(param, keys=keys,
|
result.append(gen_param_name_copy(param, keys=keys,
|
||||||
values=values, array_type=array_type))
|
values=values, array_type=array_type))
|
||||||
@@ -653,7 +652,7 @@ class Execution(Executable):
|
|||||||
key_arr, op = stmt.assignment_details[0]
|
key_arr, op = stmt.assignment_details[0]
|
||||||
# named parameter
|
# named parameter
|
||||||
if key_arr and isinstance(key_arr[0], pr.Call):
|
if key_arr and isinstance(key_arr[0], pr.Call):
|
||||||
yield op[0].name, stmt
|
yield key_arr[0].name, stmt
|
||||||
else:
|
else:
|
||||||
yield None, stmt
|
yield None, stmt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user