1
0
forked from VimPlug/jedi

add a Flow.previous attribute to be able to access the if flow from an else clause.

This commit is contained in:
Dave Halter
2014-08-05 11:17:18 +02:00
parent 54dce0e3b2
commit c44168f7ad
6 changed files with 29 additions and 9 deletions

View File

@@ -0,0 +1,7 @@
NOT_REACHABLE = object()
REACHABLE = object()
UNSURE = object()
def break_check(scope):
return UNSURE

View File

@@ -47,7 +47,10 @@ def fast_parent_copy(obj):
elif isinstance(value, list):
setattr(new_obj, key, list_rec(value))
elif isinstance(value, pr.Simple):
setattr(new_obj, key, recursion(value))
try: # because of the circular Flow.previous/Flow.next
setattr(new_obj, key, new_elements[value])
except KeyError:
setattr(new_obj, key, recursion(value))
return new_obj
def list_rec(list_obj):

View File

@@ -26,6 +26,7 @@ from jedi.evaluate import iterable
from jedi.evaluate import docstrings
from jedi.evaluate import helpers
from jedi.evaluate import param
from jedi.evaluate import flow_analysis
class Executed(pr.IsScope):
@@ -471,8 +472,14 @@ class FunctionExecution(Executed):
types = list(docstrings.find_return_types(self._evaluator, func))
for r in self.returns:
if r is not None:
if r is None:
continue
check = flow_analysis.break_check(r.parent.parent)
if check is not flow_analysis.NOT_REACHABLE:
types += self._evaluator.eval_statement(r)
if check is flow_analysis.REACHABLE:
break
return types
@memoize_default(default=())