1
0
forked from VimPlug/jedi

Disable flow analysis for finding usages

This commit is contained in:
Dave Halter
2020-01-14 18:37:10 +01:00
parent a098bf28af
commit df7080c1da
5 changed files with 18 additions and 5 deletions

View File

@@ -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()

View File

@@ -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)

View File

@@ -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
found_names = _find_defining_names(module_context, tree_name)
# 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
)

View File

@@ -1 +1,4 @@
in_stub_only: int
if 1:
in_stub_only: int
else:
in_stub_only: int

View File

@@ -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