mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
generators in *args and illegal *args like *1
This commit is contained in:
@@ -635,9 +635,14 @@ class Execution(Executable):
|
|||||||
if commands[0] == '*':
|
if commands[0] == '*':
|
||||||
arrays = evaluate.follow_call_list(commands[1:])
|
arrays = evaluate.follow_call_list(commands[1:])
|
||||||
# *args must be some sort of an array, otherwise -> ignore
|
# *args must be some sort of an array, otherwise -> ignore
|
||||||
|
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
|
if isinstance(array, 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, Generator):
|
||||||
|
for field_stmt in array.iter_content():
|
||||||
|
yield None, helpers.FakeStatement(field_stmt)
|
||||||
# **kwargs
|
# **kwargs
|
||||||
elif commands[0] == '**':
|
elif commands[0] == '**':
|
||||||
arrays = evaluate.follow_call_list(commands[1:])
|
arrays = evaluate.follow_call_list(commands[1:])
|
||||||
|
|||||||
@@ -125,3 +125,13 @@ def search_function_definition(stmt, pos):
|
|||||||
arr.parent.execution = None
|
arr.parent.execution = None
|
||||||
return call, index, False
|
return call, index, False
|
||||||
return None, 0, False
|
return None, 0, False
|
||||||
|
|
||||||
|
|
||||||
|
class FakeStatement(pr.Statement):
|
||||||
|
class SubModule():
|
||||||
|
line_offset = 0
|
||||||
|
|
||||||
|
def __init__(self, content):
|
||||||
|
cls = type(self)
|
||||||
|
p = 0, 0
|
||||||
|
super(cls, self).__init__(cls.SubModule, [], [], [content], p, p)
|
||||||
|
|||||||
@@ -166,6 +166,16 @@ exe[1]
|
|||||||
# illegal args (TypeError)
|
# illegal args (TypeError)
|
||||||
#?
|
#?
|
||||||
args_func(*1)[0]
|
args_func(*1)[0]
|
||||||
|
# iterator
|
||||||
|
#? int()
|
||||||
|
args_func(*iter([1]))[0]
|
||||||
|
|
||||||
|
# different types
|
||||||
|
e = args_func(*[1+"", {}])
|
||||||
|
#? int() str()
|
||||||
|
e[0]
|
||||||
|
#? dict()
|
||||||
|
e[1]
|
||||||
|
|
||||||
_list = [1,""]
|
_list = [1,""]
|
||||||
exe2 = args_func(_list)[0]
|
exe2 = args_func(_list)[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user