forked from VimPlug/jedi
Further small flow_analysis corrections. Keywords are only equal to other keywords if they are the same. Not in case of the same value anymore.
This commit is contained in:
@@ -210,9 +210,9 @@ class Evaluator(object):
|
||||
"""
|
||||
if isinstance(atom, pr.Name):
|
||||
# This is the first global lookup.
|
||||
stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt, pr.Scope))
|
||||
return self.find_types(stmt.get_parent_until(pr.IsScope), atom, stmt.start_pos,
|
||||
search_global=True)
|
||||
stmt = atom.get_definition()
|
||||
return self.find_types(stmt.get_parent_until(pr.IsScope), atom,
|
||||
stmt.start_pos, search_global=True)
|
||||
elif isinstance(atom, pr.Literal):
|
||||
return [compiled.create(self, atom.eval())]
|
||||
else:
|
||||
|
||||
@@ -34,9 +34,7 @@ UNSURE = Status(None, 'unsure')
|
||||
|
||||
def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
||||
from jedi.evaluate.representation import wrap
|
||||
base_scope = wrap(evaluator, base_scope)
|
||||
element_scope = wrap(evaluator, stmt.parent)
|
||||
|
||||
# Direct parents get resolved, we filter scopes that are separate branches.
|
||||
# This makes sense for autocompletion and static analysis. For actual
|
||||
# Python it doesn't matter, because we're talking about potentially
|
||||
@@ -46,6 +44,13 @@ def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
||||
if element_scope == s:
|
||||
return REACHABLE
|
||||
s = s.parent
|
||||
return _break_check(evaluator, stmt, base_scope, element_scope)
|
||||
|
||||
|
||||
def _break_check(evaluator, stmt, base_scope, element_scope):
|
||||
from jedi.evaluate.representation import wrap
|
||||
element_scope = wrap(evaluator, element_scope)
|
||||
base_scope = wrap(evaluator, base_scope)
|
||||
|
||||
reachable = REACHABLE
|
||||
if isinstance(element_scope, pr.IfStmt):
|
||||
@@ -66,7 +71,7 @@ def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
||||
return reachable
|
||||
|
||||
if base_scope != element_scope and base_scope != element_scope.parent:
|
||||
return reachable & break_check(evaluator, base_scope, element_scope.parent)
|
||||
return reachable & _break_check(evaluator, stmt, base_scope, element_scope.parent)
|
||||
return reachable
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class ExecutedParam(pr.Param):
|
||||
def eval(self, evaluator):
|
||||
types = []
|
||||
for v in self.values:
|
||||
if isinstance(v, (pr.Simple, pr.Name, pr.Literal)):
|
||||
if isinstance(v, (pr.Simple, pr.Leaf)):
|
||||
types += evaluator.eval_element(v)
|
||||
else:
|
||||
types.append(v)
|
||||
|
||||
@@ -334,6 +334,8 @@ class Keyword(Leaf):
|
||||
Make comparisons with strings easy.
|
||||
Improves the readability of the parser.
|
||||
"""
|
||||
if isinstance(other, Keyword):
|
||||
return self is other
|
||||
return self.value == other
|
||||
|
||||
def __ne__(self, other):
|
||||
|
||||
Reference in New Issue
Block a user