1
0
forked from VimPlug/jedi

Disable predefined name analysis (if stmts) for all non-analysis tasks

It's really buggy and caused quite a few issues
This commit is contained in:
Dave Halter
2018-01-29 00:56:29 +01:00
parent 8149eabdf9
commit febe65f737
5 changed files with 24 additions and 5 deletions

View File

@@ -135,7 +135,11 @@ class Evaluator(object):
if_stmt = None
break
predefined_if_name_dict = context.predefined_names.get(if_stmt)
if predefined_if_name_dict is None and if_stmt and if_stmt.type == 'if_stmt':
# TODO there's a lot of issues with this one. We actually should do
# this in a different way. Caching should only be active in certain
# cases and this all sucks.
if predefined_if_name_dict is None and if_stmt \
and if_stmt.type == 'if_stmt' and self.is_analysis:
if_stmt_test = if_stmt.children[1]
name_dicts = [{}]
# If we already did a check, we don't want to do it again -> If

View File

@@ -212,7 +212,10 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
def _check_flows(self, names):
for name in sorted(names, key=lambda name: name.start_pos, reverse=True):
check = flow_analysis.reachability_check(
self._node_context, self._parser_scope, name, self._origin_scope
context=self._node_context,
context_scope=self._parser_scope,
node=name,
origin_scope=self._origin_scope
)
if check is not flow_analysis.UNREACHABLE:
yield name

View File

@@ -56,7 +56,10 @@ class NameFinder(object):
names = self.filter_name(filters)
if self._found_predefined_types is not None and names:
check = flow_analysis.reachability_check(
self._context, self._context.tree_node, self._name)
context=self._context,
context_scope=self._context.tree_node,
node=self._name,
)
if check is flow_analysis.UNREACHABLE:
return ContextSet()
return self._found_predefined_types
@@ -102,8 +105,7 @@ class NameFinder(object):
``filters``), until a name fits.
"""
names = []
if self._context.predefined_names:
# TODO is this ok? node might not always be a tree.Name
if self._context.predefined_names and isinstance(self._name, tree.Name):
node = self._name
while node is not None and not is_scope(node):
node = node.parent

View File

@@ -65,6 +65,10 @@ class X(): pass
#? type
type(X)
if os.path.isfile():
#? ['abspath']
fails = os.path.abspath
with open('foo') as f:
for line in f.readlines():

View File

@@ -31,6 +31,12 @@ else:
#! 6 type-error-operation
z = x + y
# TODO enable this one.
#x = 3
#if x != 1:
# x.upper()
# -----------------
# With a function
# -----------------