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:
@@ -135,7 +135,11 @@ class Evaluator(object):
|
|||||||
if_stmt = None
|
if_stmt = None
|
||||||
break
|
break
|
||||||
predefined_if_name_dict = context.predefined_names.get(if_stmt)
|
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]
|
if_stmt_test = if_stmt.children[1]
|
||||||
name_dicts = [{}]
|
name_dicts = [{}]
|
||||||
# If we already did a check, we don't want to do it again -> If
|
# If we already did a check, we don't want to do it again -> If
|
||||||
|
|||||||
@@ -212,7 +212,10 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
|
|||||||
def _check_flows(self, names):
|
def _check_flows(self, names):
|
||||||
for name in sorted(names, key=lambda name: name.start_pos, reverse=True):
|
for name in sorted(names, key=lambda name: name.start_pos, reverse=True):
|
||||||
check = flow_analysis.reachability_check(
|
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:
|
if check is not flow_analysis.UNREACHABLE:
|
||||||
yield name
|
yield name
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ class NameFinder(object):
|
|||||||
names = self.filter_name(filters)
|
names = self.filter_name(filters)
|
||||||
if self._found_predefined_types is not None and names:
|
if self._found_predefined_types is not None and names:
|
||||||
check = flow_analysis.reachability_check(
|
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:
|
if check is flow_analysis.UNREACHABLE:
|
||||||
return ContextSet()
|
return ContextSet()
|
||||||
return self._found_predefined_types
|
return self._found_predefined_types
|
||||||
@@ -102,8 +105,7 @@ class NameFinder(object):
|
|||||||
``filters``), until a name fits.
|
``filters``), until a name fits.
|
||||||
"""
|
"""
|
||||||
names = []
|
names = []
|
||||||
if self._context.predefined_names:
|
if self._context.predefined_names and isinstance(self._name, tree.Name):
|
||||||
# TODO is this ok? node might not always be a tree.Name
|
|
||||||
node = self._name
|
node = self._name
|
||||||
while node is not None and not is_scope(node):
|
while node is not None and not is_scope(node):
|
||||||
node = node.parent
|
node = node.parent
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ class X(): pass
|
|||||||
#? type
|
#? type
|
||||||
type(X)
|
type(X)
|
||||||
|
|
||||||
|
if os.path.isfile():
|
||||||
|
#? ['abspath']
|
||||||
|
fails = os.path.abspath
|
||||||
|
|
||||||
|
|
||||||
with open('foo') as f:
|
with open('foo') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ else:
|
|||||||
#! 6 type-error-operation
|
#! 6 type-error-operation
|
||||||
z = x + y
|
z = x + y
|
||||||
|
|
||||||
|
|
||||||
|
# TODO enable this one.
|
||||||
|
#x = 3
|
||||||
|
#if x != 1:
|
||||||
|
# x.upper()
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# With a function
|
# With a function
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user