mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-21 21:11:13 +08:00
list comprehensions should be able to serve as an input for dynamic params as well.
This commit is contained in:
@@ -206,10 +206,10 @@ class Evaluator(object):
|
||||
# The string tokens are just operations (+, -, etc.)
|
||||
elif isinstance(element, compiled.CompiledObject):
|
||||
return [element]
|
||||
elif not isinstance(element, Token):
|
||||
return self.eval_call(element)
|
||||
else:
|
||||
elif isinstance(element, Token):
|
||||
return []
|
||||
else:
|
||||
return self.eval_call(element)
|
||||
|
||||
def eval_call(self, call):
|
||||
"""Follow a call is following a function, variable, string, etc."""
|
||||
@@ -219,7 +219,8 @@ class Evaluator(object):
|
||||
s = call
|
||||
while not s.parent.isinstance(pr.IsScope):
|
||||
s = s.parent
|
||||
return self.eval_call_path(path, s.parent, s.start_pos)
|
||||
par = s.parent
|
||||
return self.eval_call_path(path, par, s.start_pos)
|
||||
|
||||
def eval_call_path(self, path, scope, position):
|
||||
"""
|
||||
|
||||
@@ -161,6 +161,9 @@ def scan_statement_for_calls(stmt, search_name, assignment_details=False):
|
||||
if s_new.execution is not None:
|
||||
result += scan_array(s_new.execution, search_name)
|
||||
s_new = s_new.next
|
||||
elif isinstance(c, pr.ListComprehension):
|
||||
for s in c.stmt, c.middle, c.input:
|
||||
result += scan_statement_for_calls(s, search_name)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -394,3 +394,13 @@ def third():
|
||||
return list(b)
|
||||
#?
|
||||
third()[0]
|
||||
|
||||
# -----------------
|
||||
# list comprehensions
|
||||
# -----------------
|
||||
|
||||
def from_comprehension(foo):
|
||||
#? float()
|
||||
return foo
|
||||
|
||||
[from_comprehension(1.0) for n in (1,)]
|
||||
|
||||
Reference in New Issue
Block a user