mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
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:
@@ -26,7 +26,6 @@ from jedi.evaluate import docstrings
|
||||
from jedi.evaluate import iterable
|
||||
from jedi.evaluate import imports
|
||||
from jedi.evaluate import analysis
|
||||
from jedi.evaluate import precedence
|
||||
from jedi.evaluate import flow_analysis
|
||||
|
||||
|
||||
@@ -158,23 +157,6 @@ class NameFinder(object):
|
||||
if isinstance(scope, pr.Flow) \
|
||||
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):
|
||||
name_list_scope = name_list_scope.base
|
||||
return scope == name_list_scope
|
||||
|
||||
@@ -356,16 +356,6 @@ foo = \
|
||||
#? int()
|
||||
foo
|
||||
|
||||
# -----------------
|
||||
# if `is not` checks
|
||||
# -----------------
|
||||
|
||||
foo = ['a']
|
||||
if foo is not None:
|
||||
foo = ''.join(foo)
|
||||
#? str()
|
||||
foo
|
||||
|
||||
# -----------------
|
||||
# module attributes
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user