mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Small generator correction that leads to more stability in its result.
This commit is contained in:
@@ -644,10 +644,10 @@ class FunctionExecution(Executed):
|
|||||||
break
|
break
|
||||||
return types
|
return types
|
||||||
|
|
||||||
# TODO add execution_recursion_decorator
|
# TODO add execution_recursion_decorator?!
|
||||||
def get_yield_types(self):
|
def get_yield_types(self):
|
||||||
yields = self.yields
|
yields = self.yields
|
||||||
stopAt = tree.ForStmt, tree.WhileStmt, FunctionExecution
|
stopAt = tree.ForStmt, tree.WhileStmt, FunctionExecution, tree.IfStmt
|
||||||
for_parents = [(x, x.get_parent_until((stopAt))) for x in yields]
|
for_parents = [(x, x.get_parent_until((stopAt))) for x in yields]
|
||||||
|
|
||||||
# Calculate if the yields are placed within the same for loop.
|
# Calculate if the yields are placed within the same for loop.
|
||||||
@@ -668,7 +668,7 @@ class FunctionExecution(Executed):
|
|||||||
elif for_stmt == self:
|
elif for_stmt == self:
|
||||||
yields_order.append((None, [yield_]))
|
yields_order.append((None, [yield_]))
|
||||||
else:
|
else:
|
||||||
yield self.get_return_types()
|
yield self.get_return_types(check_yields=True)
|
||||||
return
|
return
|
||||||
last_for_stmt = for_stmt
|
last_for_stmt = for_stmt
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,18 @@ def simple():
|
|||||||
yield ""
|
yield ""
|
||||||
|
|
||||||
a, b = simple()
|
a, b = simple()
|
||||||
|
#? int() str()
|
||||||
|
a
|
||||||
|
# For now this is ok.
|
||||||
|
#?
|
||||||
|
b
|
||||||
|
|
||||||
|
|
||||||
|
def simple2():
|
||||||
|
yield 1
|
||||||
|
yield ""
|
||||||
|
|
||||||
|
a, b = simple2()
|
||||||
#? int()
|
#? int()
|
||||||
a
|
a
|
||||||
#? str()
|
#? str()
|
||||||
|
|||||||
Reference in New Issue
Block a user