Remove the old 'is not' logic to detect if not instances and use them to do branch predictions. This is not necessary anymore, since we now support that in a more general way (flow_analysis).

This commit is contained in:
Dave Halter
2014-08-12 18:14:03 +02:00
parent eeac77d360
commit cf32e15f65
2 changed files with 0 additions and 28 deletions

View File

@@ -26,7 +26,6 @@ from jedi.evaluate import docstrings
from jedi.evaluate import iterable from jedi.evaluate import iterable
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.evaluate import analysis from jedi.evaluate import analysis
from jedi.evaluate import precedence
from jedi.evaluate import flow_analysis from jedi.evaluate import flow_analysis
@@ -158,23 +157,6 @@ class NameFinder(object):
if isinstance(scope, pr.Flow) \ if isinstance(scope, pr.Flow) \
or isinstance(scope, pr.KeywordStatement) and scope.name == 'global': or isinstance(scope, pr.KeywordStatement) and scope.name == 'global':
# Check for `if foo is not None`, because Jedi is not interested in
# None values, so this is the only branch we actually care about.
# ATM it carries the same issue as the isinstance checks. It
# doesn't work with instance variables (self.foo).
if isinstance(scope, pr.Flow) and scope.command in ('if', 'while'):
try:
expression_list = scope.inputs[0].expression_list()
except IndexError:
pass
else:
p = precedence.create_precedence(expression_list)
if (isinstance(p, precedence.Precedence)
and p.operator.string == 'is not'
and p.right.get_code() == 'None'
and p.left.get_code() == unicode(self.name_str)):
return True
if isinstance(name_list_scope, er.Class): if isinstance(name_list_scope, er.Class):
name_list_scope = name_list_scope.base name_list_scope = name_list_scope.base
return scope == name_list_scope return scope == name_list_scope

View File

@@ -356,16 +356,6 @@ foo = \
#? int() #? int()
foo foo
# -----------------
# if `is not` checks
# -----------------
foo = ['a']
if foo is not None:
foo = ''.join(foo)
#? str()
foo
# ----------------- # -----------------
# module attributes # module attributes
# ----------------- # -----------------