forked from VimPlug/jedi
Disable flow analysis for finding usages
This commit is contained in:
@@ -104,6 +104,7 @@ class InferenceState(object):
|
||||
self.project = project
|
||||
self.access_cache = {}
|
||||
self.allow_descriptor_getattr = False
|
||||
self.flow_analysis_enabled = True
|
||||
|
||||
self.reset_recursion_limitations()
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ def _get_flow_scopes(node):
|
||||
|
||||
|
||||
def reachability_check(context, value_scope, node, origin_scope=None):
|
||||
if is_big_annoying_library(context):
|
||||
if is_big_annoying_library(context) \
|
||||
or not context.inference_state.flow_analysis_enabled:
|
||||
return UNSURE
|
||||
|
||||
first_flow_scope = get_parent_scope(node, include_flows=True)
|
||||
|
||||
@@ -92,15 +92,23 @@ def _find_global_variables(names, search_name):
|
||||
|
||||
|
||||
def find_references(module_context, tree_name):
|
||||
inf = module_context.inference_state
|
||||
search_name = tree_name.value
|
||||
|
||||
# We disable flow analysis, because if we have ifs that are only true in
|
||||
# certain cases, we want both sides.
|
||||
try:
|
||||
inf.flow_analysis_enabled = False
|
||||
found_names = _find_defining_names(module_context, tree_name)
|
||||
finally:
|
||||
inf.flow_analysis_enabled = True
|
||||
|
||||
found_names_dct = _dictionarize(found_names)
|
||||
|
||||
module_contexts = set(d.get_root_context() for d in found_names)
|
||||
module_contexts = set(m for m in module_contexts if not m.is_compiled())
|
||||
|
||||
non_matching_reference_maps = {}
|
||||
inf = module_context.inference_state
|
||||
potential_modules = imports.get_module_contexts_containing_name(
|
||||
inf, module_contexts, search_name
|
||||
)
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
if 1:
|
||||
in_stub_only: int
|
||||
else:
|
||||
in_stub_only: int
|
||||
|
||||
@@ -358,5 +358,5 @@ from stub_folder import with_stub
|
||||
#< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10)
|
||||
with_stub.stub_function
|
||||
from stub_folder.with_stub_folder.nested_stub_only import in_stub_only
|
||||
#< ('stub:stub_folder.with_stub_folder.nested_stub_only', 1, 0), ('stubs', 64, 17), (-2, 58), (0, 0)
|
||||
#< ('stub:stub_folder.with_stub_folder.nested_stub_only', 2, 4), ('stub:stub_folder.with_stub_folder.nested_stub_only', 4, 4), ('stubs', 64, 17), (-2, 58), (0, 0)
|
||||
in_stub_only
|
||||
|
||||
Reference in New Issue
Block a user