From 239f0d72130b8aec446f09d560077acd7121b90c Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 11 Nov 2015 11:34:18 +0100 Subject: [PATCH] Small generator correction that leads to more stability in its result. --- jedi/evaluate/representation.py | 6 +++--- test/completion/generators.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 81382c45..b7652871 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -644,10 +644,10 @@ class FunctionExecution(Executed): break return types - # TODO add execution_recursion_decorator + # TODO add execution_recursion_decorator?! def get_yield_types(self): 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] # Calculate if the yields are placed within the same for loop. @@ -668,7 +668,7 @@ class FunctionExecution(Executed): elif for_stmt == self: yields_order.append((None, [yield_])) else: - yield self.get_return_types() + yield self.get_return_types(check_yields=True) return last_for_stmt = for_stmt diff --git a/test/completion/generators.py b/test/completion/generators.py index 96aa2b66..07c4b72f 100644 --- a/test/completion/generators.py +++ b/test/completion/generators.py @@ -131,6 +131,18 @@ def simple(): yield "" a, b = simple() +#? int() str() +a +# For now this is ok. +#? +b + + +def simple2(): + yield 1 + yield "" + +a, b = simple2() #? int() a #? str()