mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
fix a keyword statement issue
This commit is contained in:
@@ -37,10 +37,10 @@ def break_check(evaluator, base_scope, element_scope):
|
|||||||
types = evaluator.eval_statement(element_scope.inputs[0])
|
types = evaluator.eval_statement(element_scope.inputs[0])
|
||||||
values = set(x.py__bool__() for x in types)
|
values = set(x.py__bool__() for x in types)
|
||||||
if len(values) == 1:
|
if len(values) == 1:
|
||||||
return Status.lookup_table[values.pop()]
|
reachable = Status.lookup_table[values.pop()]
|
||||||
else:
|
else:
|
||||||
return UNSURE
|
return UNSURE
|
||||||
|
|
||||||
if base_scope != element_scope.parent:
|
if base_scope != element_scope and base_scope != element_scope.parent:
|
||||||
return reachable & break_check(base_scope, element_scope.parent)
|
return reachable & break_check(evaluator, base_scope, element_scope.parent)
|
||||||
return UNSURE
|
return reachable
|
||||||
|
|||||||
@@ -79,6 +79,10 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
|
|
||||||
return actual
|
return actual
|
||||||
|
|
||||||
|
def py__bool__(self):
|
||||||
|
# Signalize that we don't know about the bool type.
|
||||||
|
return None
|
||||||
|
|
||||||
@memoize_default()
|
@memoize_default()
|
||||||
def _get_method_execution(self, func):
|
def _get_method_execution(self, func):
|
||||||
func = get_instance_el(self._evaluator, self, func, True)
|
func = get_instance_el(self._evaluator, self, func, True)
|
||||||
@@ -472,12 +476,13 @@ class FunctionExecution(Executed):
|
|||||||
|
|
||||||
types = list(docstrings.find_return_types(self._evaluator, func))
|
types = list(docstrings.find_return_types(self._evaluator, func))
|
||||||
for r in self.returns:
|
for r in self.returns:
|
||||||
if r is None:
|
# r is a KeywordStatement
|
||||||
|
if r.stmt is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
check = flow_analysis.break_check(self._evaluator, self, r.parent.parent)
|
check = flow_analysis.break_check(self._evaluator, self, r.parent)
|
||||||
if check is not flow_analysis.UNREACHABLE:
|
if check is not flow_analysis.UNREACHABLE:
|
||||||
types += self._evaluator.eval_statement(r)
|
types += self._evaluator.eval_statement(r.stmt)
|
||||||
if check is flow_analysis.REACHABLE:
|
if check is flow_analysis.REACHABLE:
|
||||||
break
|
break
|
||||||
return types
|
return types
|
||||||
|
|||||||
@@ -568,11 +568,12 @@ class Parser(object):
|
|||||||
kw_stmt = pr.KeywordStatement(tok_str, s,
|
kw_stmt = pr.KeywordStatement(tok_str, s,
|
||||||
use_as_parent_scope, stmt)
|
use_as_parent_scope, stmt)
|
||||||
self._scope.statements.append(kw_stmt)
|
self._scope.statements.append(kw_stmt)
|
||||||
func.returns.append(stmt)
|
func.returns.append(kw_stmt)
|
||||||
# start_pos is the one of the return statement
|
# start_pos is the one of the return statement
|
||||||
stmt.start_pos = s
|
stmt.start_pos = s
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
debug.warning('return in non-function')
|
debug.warning('return in non-function')
|
||||||
|
stmt = None
|
||||||
elif tok_str == 'assert':
|
elif tok_str == 'assert':
|
||||||
stmt, tok = self._parse_statement()
|
stmt, tok = self._parse_statement()
|
||||||
if stmt is not None:
|
if stmt is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user