mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-20 04:21:13 +08:00
isinstance checks should now also work within functions. -> fixes #39
This commit is contained in:
@@ -1125,6 +1125,8 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
|
|||||||
result = []
|
result = []
|
||||||
# compare func uses the tuple of line/indent = line/column
|
# compare func uses the tuple of line/indent = line/column
|
||||||
comparison_func = lambda name: (name.start_pos)
|
comparison_func = lambda name: (name.start_pos)
|
||||||
|
check_for_param = lambda p: isinstance(p, parsing.Param) \
|
||||||
|
and not p.is_generated
|
||||||
for nscope, name_list in scope_generator:
|
for nscope, name_list in scope_generator:
|
||||||
break_scopes = []
|
break_scopes = []
|
||||||
# here is the position stuff happening (sorting of variables)
|
# here is the position stuff happening (sorting of variables)
|
||||||
@@ -1150,13 +1152,17 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
|
|||||||
if not name.parent() or p == s:
|
if not name.parent() or p == s:
|
||||||
break
|
break
|
||||||
break_scopes.append(p)
|
break_scopes.append(p)
|
||||||
# if there are results, ignore the other scopes
|
# if there are results, ignore the other scopes, if params are in
|
||||||
if result:
|
# there, we still need to check flows, if they contain information.
|
||||||
|
if result and not [r for r in result if check_for_param(r)]:
|
||||||
break
|
break
|
||||||
|
|
||||||
while flow_scope:
|
while flow_scope:
|
||||||
result = dynamic.check_flow_information(flow_scope, name_str,
|
n = dynamic.check_flow_information(flow_scope, name_str,
|
||||||
position)
|
position)
|
||||||
|
if n and result:
|
||||||
|
result = n + [p for p in result if not check_for_param(r)]
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
break
|
break
|
||||||
if flow_scope == nscope:
|
if flow_scope == nscope:
|
||||||
|
|||||||
@@ -28,3 +28,13 @@ assert not isinstance(ass, int):
|
|||||||
if 2:
|
if 2:
|
||||||
#? str()
|
#? str()
|
||||||
ass
|
ass
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# in functions
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
def fooooo(obj):
|
||||||
|
if isinstance(obj, datetime.datetime):
|
||||||
|
#? datetime.datetime
|
||||||
|
obj
|
||||||
|
|||||||
Reference in New Issue
Block a user