mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix: flow analysis crashed when using in combination with different modules.
This commit is contained in:
@@ -72,9 +72,14 @@ def _break_check(evaluator, stmt, base_scope, element_scope):
|
||||
if reachable in (UNREACHABLE, UNSURE):
|
||||
return reachable
|
||||
|
||||
if element_scope.type == 'file_input':
|
||||
# The definition is in another module and therefore just return what we
|
||||
# have generated.
|
||||
return reachable
|
||||
if base_scope != element_scope and base_scope != element_scope.parent:
|
||||
return reachable & _break_check(evaluator, stmt, base_scope, element_scope.parent)
|
||||
return reachable
|
||||
else:
|
||||
return reachable
|
||||
|
||||
|
||||
def _check_if(evaluator, node):
|
||||
|
||||
@@ -238,3 +238,20 @@ else:
|
||||
s = str()
|
||||
#? str()
|
||||
possible_recursion_error(s)
|
||||
|
||||
|
||||
# -----------------
|
||||
# In combination with imports
|
||||
# -----------------
|
||||
|
||||
from import_tree import flow_import
|
||||
|
||||
if 1 == flow_import.env:
|
||||
a = 1
|
||||
elif 2 == flow_import.env:
|
||||
a = ''
|
||||
elif 3 == flow_import.env:
|
||||
a = 1.0
|
||||
|
||||
#? int() str()
|
||||
a
|
||||
|
||||
4
test/completion/import_tree/flow_import.py
Normal file
4
test/completion/import_tree/flow_import.py
Normal file
@@ -0,0 +1,4 @@
|
||||
if name:
|
||||
env = 1
|
||||
else:
|
||||
env = 2
|
||||
@@ -65,7 +65,7 @@ import datetime.date
|
||||
from import_tree.pkg import pkg
|
||||
#? 22 ['mod1']
|
||||
from import_tree.pkg. import mod1
|
||||
#? 17 ['mod1', 'mod2', 'random', 'pkg', 'rename1', 'rename2', 'recurse_class1', 'recurse_class2', 'invisible_pkg']
|
||||
#? 17 ['mod1', 'mod2', 'random', 'pkg', 'rename1', 'rename2', 'recurse_class1', 'recurse_class2', 'invisible_pkg', 'flow_import']
|
||||
from import_tree. import pkg
|
||||
|
||||
#? 18 ['pkg']
|
||||
|
||||
Reference in New Issue
Block a user