mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 10:37:52 +08:00
Fix isinstance issues.
This commit is contained in:
@@ -401,7 +401,26 @@ def check_flow_information(evaluator, flow, search_name_part, pos):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _check_isinstance_type(evaluator, stmt, search_name_part):
|
def _check_isinstance_type(evaluator, stmt, search_name):
|
||||||
|
def names(call, use_previous=False):
|
||||||
|
def check(call):
|
||||||
|
while call is not None:
|
||||||
|
if not isinstance(call, pr.Call): # Could be an Array.
|
||||||
|
raise ValueError
|
||||||
|
yield unicode(call.name)
|
||||||
|
if use_previous:
|
||||||
|
call = call.previous
|
||||||
|
else:
|
||||||
|
call = call.next
|
||||||
|
|
||||||
|
try:
|
||||||
|
if use_previous:
|
||||||
|
return list(check(call))
|
||||||
|
else:
|
||||||
|
return list(reversed(list(check(call))))
|
||||||
|
except ValueError:
|
||||||
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
expression_list = stmt.expression_list()
|
expression_list = stmt.expression_list()
|
||||||
# this might be removed if we analyze and, etc
|
# this might be removed if we analyze and, etc
|
||||||
@@ -418,8 +437,7 @@ def _check_isinstance_type(evaluator, stmt, search_name_part):
|
|||||||
assert len(classes) == 1
|
assert len(classes) == 1
|
||||||
assert isinstance(obj[0], pr.Call)
|
assert isinstance(obj[0], pr.Call)
|
||||||
|
|
||||||
# names fit?
|
assert names(obj[0]) == names(search_name.parent, search_name)
|
||||||
assert unicode(obj[0].name) == unicode(search_name_part.parent)
|
|
||||||
assert isinstance(classes[0], pr.StatementElement) # can be type or tuple
|
assert isinstance(classes[0], pr.StatementElement) # can be type or tuple
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user