summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCeridwen <ceridwenv@gmail.com>2015-11-06 18:06:45 -0500
committerCeridwen <ceridwenv@gmail.com>2015-11-06 18:06:45 -0500
commitcc7ea53df2383cd188e2b0958b231e1eb70fc79c (patch)
treea8170ee5867f49721c3d071c322ef3815cc608b9
parent67dc5fda9c487bbbe6b3ac1e98af76b63d13396e (diff)
downloadastroid-cc7ea53df2383cd188e2b0958b231e1eb70fc79c.tar.gz
Rename Uninferable and instatiate_class
-rw-r--r--astroid/__init__.py2
-rw-r--r--astroid/arguments.py24
-rw-r--r--astroid/bases.py16
-rw-r--r--astroid/brain/brain_builtin_inference.py46
-rw-r--r--astroid/brain/brain_stdlib.py4
-rw-r--r--astroid/builder.py2
-rw-r--r--astroid/decorators.py2
-rw-r--r--astroid/helpers.py8
-rw-r--r--astroid/inference.py76
-rw-r--r--astroid/manager.py2
-rw-r--r--astroid/node_classes.py14
-rw-r--r--astroid/protocols.py32
-rw-r--r--astroid/scoped_nodes.py38
-rw-r--r--astroid/tests/unittest_brain.py2
-rw-r--r--astroid/tests/unittest_builder.py2
-rw-r--r--astroid/tests/unittest_helpers.py8
-rw-r--r--astroid/tests/unittest_inference.py108
-rw-r--r--astroid/tests/unittest_lookup.py2
-rw-r--r--astroid/tests/unittest_nodes.py4
-rw-r--r--astroid/tests/unittest_protocols.py10
-rw-r--r--astroid/tests/unittest_regrtest.py2
-rw-r--r--astroid/tests/unittest_scoped_nodes.py6
-rw-r--r--astroid/util.py4
23 files changed, 207 insertions, 207 deletions
diff --git a/astroid/__init__.py b/astroid/__init__.py
index f67bbf9..973bb84 100644
--- a/astroid/__init__.py
+++ b/astroid/__init__.py
@@ -63,7 +63,7 @@ from astroid.bases import Instance, BoundMethod, UnboundMethod
from astroid.node_classes import are_exclusive, unpack_infer
from astroid.scoped_nodes import builtin_lookup
from astroid.builder import parse
-from astroid.util import YES
+from astroid.util import Uninferable
# make a manager instance (borg) accessible from astroid package
from astroid.manager import AstroidManager
diff --git a/astroid/arguments.py b/astroid/arguments.py
index 6483189..7136834 100644
--- a/astroid/arguments.py
+++ b/astroid/arguments.py
@@ -44,11 +44,11 @@ class CallSite(object):
self.positional_arguments = [
arg for arg in self._unpacked_args
- if arg is not util.YES
+ if arg is not util.Uninferable
]
self.keyword_arguments = {
key: value for key, value in self._unpacked_kwargs.items()
- if value is not util.YES
+ if value is not util.Uninferable
}
@classmethod
@@ -87,29 +87,29 @@ class CallSite(object):
try:
inferred = next(value.infer(context=context))
except exceptions.InferenceError:
- values[name] = util.YES
+ values[name] = util.Uninferable
continue
if not isinstance(inferred, nodes.Dict):
# Not something we can work with.
- values[name] = util.YES
+ values[name] = util.Uninferable
continue
for dict_key, dict_value in inferred.items:
try:
dict_key = next(dict_key.infer(context=context))
except exceptions.InferenceError:
- values[name] = util.YES
+ values[name] = util.Uninferable
continue
if not isinstance(dict_key, nodes.Const):
- values[name] = util.YES
+ values[name] = util.Uninferable
continue
if not isinstance(dict_key.value, six.string_types):
- values[name] = util.YES
+ values[name] = util.Uninferable
continue
if dict_key.value in values:
# The name is already in the dictionary
- values[dict_key.value] = util.YES
+ values[dict_key.value] = util.Uninferable
self.duplicated_keywords.add(dict_key.value)
continue
values[dict_key.value] = dict_value
@@ -126,14 +126,14 @@ class CallSite(object):
try:
inferred = next(arg.value.infer(context=context))
except exceptions.InferenceError:
- values.append(util.YES)
+ values.append(util.Uninferable)
continue
- if inferred is util.YES:
- values.append(util.YES)
+ if inferred is util.Uninferable:
+ values.append(util.Uninferable)
continue
if not hasattr(inferred, 'elts'):
- values.append(util.YES)
+ values.append(util.Uninferable)
continue
values.extend(inferred.elts)
else:
diff --git a/astroid/bases.py b/astroid/bases.py
index 15cf579..05633b8 100644
--- a/astroid/bases.py
+++ b/astroid/bases.py
@@ -53,7 +53,7 @@ def _is_property(meth):
if PROPERTIES.intersection(meth.decoratornames()):
return True
stripped = {name.split(".")[-1] for name in meth.decoratornames()
- if name is not util.YES}
+ if name is not util.Uninferable}
return any(name in stripped for name in POSSIBLE_PROPERTIES)
@@ -89,7 +89,7 @@ def _infer_stmts(stmts, context, frame=None):
context = contextmod.InferenceContext()
for stmt in stmts:
- if stmt is util.YES:
+ if stmt is util.Uninferable:
yield stmt
inferred = True
continue
@@ -101,7 +101,7 @@ def _infer_stmts(stmts, context, frame=None):
except exceptions.NameInferenceError:
continue
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
inferred = True
if not inferred:
raise exceptions.InferenceError(
@@ -115,14 +115,14 @@ def _infer_method_result_truth(instance, method_name, context):
meth = next(instance.igetattr(method_name, context=context), None)
if meth and hasattr(meth, 'infer_call_result'):
if not meth.callable():
- return util.YES
+ return util.Uninferable
for value in meth.infer_call_result(instance, context=context):
- if value is util.YES:
+ if value is util.Uninferable:
return value
inferred = next(value.infer(context=context))
return inferred.bool_value()
- return util.YES
+ return util.Uninferable
class Instance(Proxy):
@@ -205,7 +205,7 @@ class Instance(Proxy):
"""infer what a class instance is returning when called"""
inferred = False
for node in self._proxied.igetattr('__call__', context):
- if node is util.YES or not node.callable():
+ if node is util.Uninferable or not node.callable():
continue
for res in node.infer_call_result(caller, context):
inferred = True
@@ -296,7 +296,7 @@ class UnboundMethod(Proxy):
if (self._proxied.name == '__new__' and
self._proxied.parent.frame().qname() == '%s.object' % BUILTINS):
infer = caller.args[0].infer() if caller.args else []
- return ((x is util.YES and x or Instance(x)) for x in infer)
+ return ((x is util.Uninferable and x or Instance(x)) for x in infer)
return self._proxied.infer_call_result(caller, context)
def bool_value(self):
diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py
index eb61b70..47ef7f3 100644
--- a/astroid/brain/brain_builtin_inference.py
+++ b/astroid/brain/brain_builtin_inference.py
@@ -120,10 +120,10 @@ def _generic_inference(node, context, node_type, transform):
inferred = next(arg.infer(context=context))
except (InferenceError, StopIteration):
raise UseInferenceDefault()
- if inferred is util.YES:
+ if inferred is util.Uninferable:
raise UseInferenceDefault()
transformed = transform(inferred)
- if not transformed or transformed is util.YES:
+ if not transformed or transformed is util.Uninferable:
raise UseInferenceDefault()
return transformed
@@ -293,7 +293,7 @@ def infer_super(node, context=None):
if scope.type == 'classmethod':
mro_type = cls
else:
- mro_type = cls.instanciate_class()
+ mro_type = cls.instantiate_class()
else:
# TODO(cpopa): support flow control (multiple inference values).
try:
@@ -305,7 +305,7 @@ def infer_super(node, context=None):
except InferenceError:
raise UseInferenceDefault
- if mro_pointer is util.YES or mro_type is util.YES:
+ if mro_pointer is util.Uninferable or mro_type is util.Uninferable:
# No way we could understand this.
raise UseInferenceDefault
@@ -329,11 +329,11 @@ def _infer_getattr_args(node, context):
except InferenceError:
raise UseInferenceDefault
- if obj is util.YES or attr is util.YES:
+ if obj is util.Uninferable or attr is util.Uninferable:
# If one of the arguments is something we can't infer,
# then also make the result of the getattr call something
# which is unknown.
- return util.YES, util.YES
+ return util.Uninferable, util.Uninferable
is_string = (isinstance(attr, nodes.Const) and
isinstance(attr.value, six.string_types))
@@ -346,13 +346,13 @@ def _infer_getattr_args(node, context):
def infer_getattr(node, context=None):
"""Understand getattr calls
- If one of the arguments is an YES object, then the
- result will be an YES object. Otherwise, the normal attribute
+ If one of the arguments is an Uninferable object, then the
+ result will be an Uninferable object. Otherwise, the normal attribute
lookup will be done.
"""
obj, attr = _infer_getattr_args(node, context)
- if obj is util.YES or attr is util.YES or not hasattr(obj, 'igetattr'):
- return util.YES
+ if obj is util.Uninferable or attr is util.Uninferable or not hasattr(obj, 'igetattr'):
+ return util.Uninferable
try:
return next(obj.igetattr(attr, context=context))
@@ -373,17 +373,17 @@ def infer_hasattr(node, context=None):
This always guarantees three possible outcomes for calling
hasattr: Const(False) when we are sure that the object
doesn't have the intended attribute, Const(True) when
- we know that the object has the attribute and YES
+ we know that the object has the attribute and Uninferable
when we are unsure of the outcome of the function call.
"""
try:
obj, attr = _infer_getattr_args(node, context)
- if obj is util.YES or attr is util.YES or not hasattr(obj, 'getattr'):
- return util.YES
+ if obj is util.Uninferable or attr is util.Uninferable or not hasattr(obj, 'getattr'):
+ return util.Uninferable
obj.getattr(attr, context=context)
except UseInferenceDefault:
# Can't infer something from this function call.
- return util.YES
+ return util.Uninferable
except AttributeInferenceError:
# Doesn't have it.
return nodes.Const(False)
@@ -406,9 +406,9 @@ def infer_callable(node, context=None):
try:
inferred = next(argument.infer(context=context))
except InferenceError:
- return util.YES
- if inferred is util.YES:
- return util.YES
+ return util.Uninferable
+ if inferred is util.Uninferable:
+ return util.Uninferable
return nodes.Const(inferred.callable())
@@ -425,13 +425,13 @@ def infer_bool(node, context=None):
try:
inferred = next(argument.infer(context=context))
except InferenceError:
- return util.YES
- if inferred is util.YES:
- return util.YES
+ return util.Uninferable
+ if inferred is util.Uninferable:
+ return util.Uninferable
bool_value = inferred.bool_value()
- if bool_value is util.YES:
- return util.YES
+ if bool_value is util.Uninferable:
+ return util.Uninferable
return nodes.Const(bool_value)
@@ -451,7 +451,7 @@ def infer_slice(node, context=None):
args = list(map(helpers.safe_infer, args))
for arg in args:
- if not arg or arg is util.YES:
+ if not arg or arg is util.Uninferable:
raise UseInferenceDefault
if not isinstance(arg, nodes.Const):
raise UseInferenceDefault
diff --git a/astroid/brain/brain_stdlib.py b/astroid/brain/brain_stdlib.py
index a03358f..6a988d6 100644
--- a/astroid/brain/brain_stdlib.py
+++ b/astroid/brain/brain_stdlib.py
@@ -23,7 +23,7 @@ def infer_func_form(node, base_type, context=None, enum=False):
def infer_first(node):
try:
value = next(node.infer(context=context))
- if value is util.YES:
+ if value is util.Uninferable:
raise UseInferenceDefault()
else:
return value
@@ -330,7 +330,7 @@ def infer_enum_class(node):
fake.parent = target.parent
for method in node.mymethods():
fake.locals[method.name] = [method]
- new_targets.append(fake.instanciate_class())
+ new_targets.append(fake.instantiate_class())
node.locals[local] = new_targets
break
return node
diff --git a/astroid/builder.py b/astroid/builder.py
index 4db4051..9e06ef7 100644
--- a/astroid/builder.py
+++ b/astroid/builder.py
@@ -227,7 +227,7 @@ class AstroidBuilder(raw_building.InspectBuilder):
try:
frame = node.frame()
for inferred in node.expr.infer():
- if inferred is util.YES:
+ if inferred is util.Uninferable:
continue
try:
if inferred.__class__ is bases.Instance:
diff --git a/astroid/decorators.py b/astroid/decorators.py
index 2f02962..3e9f409 100644
--- a/astroid/decorators.py
+++ b/astroid/decorators.py
@@ -123,7 +123,7 @@ def yes_if_nothing_inferred(func, instance, args, kwargs):
inferred = True
yield node
if not inferred:
- yield util.YES
+ yield util.Uninferable
@wrapt.decorator
diff --git a/astroid/helpers.py b/astroid/helpers.py
index d4cd0dd..6d48b0d 100644
--- a/astroid/helpers.py
+++ b/astroid/helpers.py
@@ -94,9 +94,9 @@ def object_type(node, context=None):
try:
types = set(_object_type(node, context))
except exceptions.InferenceError:
- return util.YES
+ return util.Uninferable
if len(types) > 1 or not types:
- return util.YES
+ return util.Uninferable
return list(types)[0]
@@ -140,7 +140,7 @@ def has_known_bases(klass, context=None):
def _type_check(type1, type2):
if not all(map(has_known_bases, (type1, type2))):
- return util.YES
+ return util.Uninferable
if not all([type1.newstyle, type2.newstyle]):
return False
@@ -148,7 +148,7 @@ def _type_check(type1, type2):
return type1 in type2.mro()[:-1]
except exceptions.MroError:
# The MRO is invalid.
- return util.YES
+ return util.Uninferable
def is_subtype(type1, type2):
diff --git a/astroid/inference.py b/astroid/inference.py
index fda4546..47f60d9 100644
--- a/astroid/inference.py
+++ b/astroid/inference.py
@@ -108,7 +108,7 @@ def infer_call(self, context=None):
keywords=self.keywords)
callcontext.boundnode = None
for callee in self.func.infer(context):
- if callee is util.YES:
+ if callee is util.Uninferable:
yield callee
continue
try:
@@ -168,7 +168,7 @@ nodes.ImportFrom._infer = infer_import_from
def infer_attribute(self, context=None):
"""infer an Attribute node by using getattr on the associated object"""
for owner in self.expr.infer(context):
- if owner is util.YES:
+ if owner is util.Uninferable:
yield owner
continue
try:
@@ -240,13 +240,13 @@ def infer_subscript(self, context=None):
"""
value = next(self.value.infer(context))
- if value is util.YES:
- yield util.YES
+ if value is util.Uninferable:
+ yield util.Uninferable
return
index = next(self.slice.infer(context))
- if index is util.YES:
- yield util.YES
+ if index is util.Uninferable:
+ yield util.Uninferable
return
if value.__class__ == bases.Instance:
@@ -280,8 +280,8 @@ def infer_subscript(self, context=None):
# Prevent inferring if the inferred subscript
# is the same as the original subscripted object.
- if self is assigned or assigned is util.YES:
- yield util.YES
+ if self is assigned or assigned is util.Uninferable:
+ yield util.Uninferable
return
for inferred in assigned.infer(context):
yield inferred
@@ -312,31 +312,31 @@ def _infer_boolop(self, context=None):
try:
values = [value.infer(context=context) for value in values]
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
return
for pair in itertools.product(*values):
- if any(item is util.YES for item in pair):
- # Can't infer the final result, just yield YES.
- yield util.YES
+ if any(item is util.Uninferable for item in pair):
+ # Can't infer the final result, just yield Uninferable.
+ yield util.Uninferable
continue
bool_values = [item.bool_value() for item in pair]
- if any(item is util.YES for item in bool_values):
- # Can't infer the final result, just yield YES.
- yield util.YES
+ if any(item is util.Uninferable for item in bool_values):
+ # Can't infer the final result, just yield Uninferable.
+ yield util.Uninferable
continue
# Since the boolean operations are short circuited operations,
# this code yields the first value for which the predicate is True
# and if no value respected the predicate, then the last value will
- # be returned (or YES if there was no last value).
+ # be returned (or Uninferable if there was no last value).
# This is conforming to the semantics of `and` and `or`:
# 1 and 0 -> 1
# 0 and 1 -> 0
# 1 or 0 -> 1
# 0 or 1 -> 1
- value = util.YES
+ value = util.Uninferable
for value, bool_value in zip(pair, bool_values):
if predicate(bool_value):
yield value
@@ -359,7 +359,7 @@ def _filter_operation_errors(self, infer_callable, context, error):
# For the sake of .infer(), we don't care about operation
# errors, which is the job of pylint. So return something
# which shows that we can't infer the result.
- yield util.YES
+ yield util.Uninferable
else:
yield result
@@ -377,12 +377,12 @@ def _infer_unaryop(self, context=None):
if meth is None:
# `not node`. Determine node's boolean
# value and negate its result, unless it is
- # YES, which will be returned as is.
+ # Uninferable, which will be returned as is.
bool_value = operand.bool_value()
- if bool_value is not util.YES:
+ if bool_value is not util.Uninferable:
yield nodes.const_factory(not bool_value)
else:
- yield util.YES
+ yield util.Uninferable
else:
if not isinstance(operand, bases.Instance):
# The operation was used on something which
@@ -393,7 +393,7 @@ def _infer_unaryop(self, context=None):
try:
meth = operand.getattr(meth, context=context)[0]
inferred = next(meth.infer(context=context))
- if inferred is util.YES or not inferred.callable():
+ if inferred is util.Uninferable or not inferred.callable():
continue
context = contextmod.copy_context(context)
@@ -409,7 +409,7 @@ def _infer_unaryop(self, context=None):
# The unary operation special method was not found.
yield util.BadUnaryOperationMessage(operand, self.op, exc)
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
@decorators.raise_if_nothing_inferred
@@ -570,23 +570,23 @@ def _infer_binary_operation(left, right, op, context, flow_factory):
except exceptions.AttributeInferenceError:
continue
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
return
else:
- if any(result is util.YES for result in results):
- yield util.YES
+ if any(result is util.Uninferable for result in results):
+ yield util.Uninferable
return
# TODO(cpopa): since the inferrence engine might return
# more values than are actually possible, we decide
- # to return util.YES if we have union types.
+ # to return util.Uninferable if we have union types.
if all(map(_is_not_implemented, results)):
continue
not_implemented = sum(1 for result in results
if _is_not_implemented(result))
if not_implemented and not_implemented != len(results):
# Can't decide yet what this is, not yet though.
- yield util.YES
+ yield util.Uninferable
return
for result in results:
@@ -612,15 +612,15 @@ def _infer_binop(self, context):
rhs_context = context.clone()
for lhs in left.infer(context=lhs_context):
- if lhs is util.YES:
+ if lhs is util.Uninferable:
# Don't know how to process this.
- yield util.YES
+ yield util.Uninferable
return
for rhs in right.infer(context=rhs_context):
- if rhs is util.YES:
+ if rhs is util.Uninferable:
# Don't know how to process this.
- yield util.YES
+ yield util.Uninferable
return
results = _infer_binary_operation(lhs, rhs, op,
@@ -646,9 +646,9 @@ def _infer_augassign(self, context=None):
op = self.op
for lhs in self.target.infer_lhs(context=context):
- if lhs is util.YES:
+ if lhs is util.Uninferable:
# Don't know how to process this.
- yield util.YES
+ yield util.Uninferable
return
# TODO(cpopa): if we have A() * A(), trying to infer
@@ -658,9 +658,9 @@ def _infer_augassign(self, context=None):
rhs_context = context.clone()
rhs_context.path = set()
for rhs in self.value.infer(context=rhs_context):
- if rhs is util.YES:
+ if rhs is util.Uninferable:
# Don't know how to process this.
- yield util.YES
+ yield util.Uninferable
return
results = _infer_binary_operation(lhs, rhs, op,
@@ -708,14 +708,14 @@ nodes.AssignAttr._infer = infer_assign
@decorators.path_wrapper
def infer_empty_node(self, context=None):
if not self.has_underlying_object():
- yield util.YES
+ yield util.Uninferable
else:
try:
for inferred in MANAGER.infer_ast_from_something(self.object,
context=context):
yield inferred
except exceptions.AstroidError:
- yield util.YES
+ yield util.Uninferable
nodes.EmptyNode._infer = infer_empty_node
diff --git a/astroid/manager.py b/astroid/manager.py
index c14125f..0f6673d 100644
--- a/astroid/manager.py
+++ b/astroid/manager.py
@@ -252,7 +252,7 @@ class AstroidManager(object):
yield inferred
else:
for inferred in modastroid.igetattr(name, context):
- yield inferred.instanciate_class()
+ yield inferred.instantiate_class()
def register_failed_import_hook(self, hook):
"""Registers a hook to resolve imports that cannot be found otherwise.
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index 5a92210..3dbba34 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -56,9 +56,9 @@ def unpack_infer(stmt, context=None):
if inferred is stmt:
yield inferred
return
- # else, infer recursivly, except YES object that should be returned as is
+ # else, infer recursivly, except Uninferable object that should be returned as is
for inferred in stmt.infer(context):
- if inferred is util.YES:
+ if inferred is util.Uninferable:
yield inferred
else:
for inf_inf in unpack_infer(inferred, context):
@@ -426,8 +426,8 @@ class NodeNG(object):
PendingDeprecationWarning, stacklevel=2)
return self.inferred()
- def instanciate_class(self):
- """instanciate a node if it is a ClassDef node, else return self"""
+ def instantiate_class(self):
+ """instantiate a node if it is a ClassDef node, else return self"""
return self
def has_base(self, node):
@@ -572,10 +572,10 @@ class NodeNG(object):
method.
* True. Most of constructs are True by default:
classes, functions, modules etc
- * YES: the inference engine is uncertain of the
+ * Uninferable: the inference engine is uncertain of the
node's value.
"""
- return util.YES
+ return util.Uninferable
class Statement(NodeNG):
@@ -1292,7 +1292,7 @@ class Dict(NodeNG, bases.Instance):
except IndexError:
continue
for inferredkey in key.infer(context):
- if inferredkey is util.YES:
+ if inferredkey is util.Uninferable:
continue
if isinstance(inferredkey, Const) \
and inferredkey.value == lookup_key:
diff --git a/astroid/protocols.py b/astroid/protocols.py
index 5809e4a..6b6c0c0 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -127,12 +127,12 @@ def const_infer_binary_op(self, operator, other, context, _):
# ArithmeticError is not enough: float >> float is a TypeError
yield not_implemented
except Exception: # pylint: disable=broad-except
- yield util.YES
+ yield util.Uninferable
except TypeError:
yield not_implemented
elif isinstance(self.value, six.string_types) and operator == '%':
# TODO(cpopa): implement string interpolation later on.
- yield util.YES
+ yield util.Uninferable
else:
yield not_implemented
@@ -145,7 +145,7 @@ def _multiply_seq_by_int(self, other, context):
for elt in self.elts:
infered = helpers.safe_infer(elt, context)
if infered is None:
- infered = util.YES
+ infered = util.Uninferable
elts.append(infered)
node.elts = elts * other.value
return node
@@ -157,9 +157,9 @@ def tl_infer_binary_op(self, operator, other, context, method):
if isinstance(other, self.__class__) and operator == '+':
node = self.__class__()
elts = [n for elt in self.elts for n in elt.infer(context)
- if not n is util.YES]
+ if not n is util.Uninferable]
elts += [n for elt in other.elts for n in elt.infer(context)
- if not n is util.YES]
+ if not n is util.Uninferable]
node.elts = elts
yield node
elif isinstance(other, nodes.Const) and operator == '*':
@@ -171,7 +171,7 @@ def tl_infer_binary_op(self, operator, other, context, method):
# Verify if the instance supports __index__.
as_index = helpers.class_instance_as_index(other)
if not as_index:
- yield util.YES
+ yield util.Uninferable
else:
yield _multiply_seq_by_int(self, as_index, context)
else:
@@ -206,7 +206,7 @@ def _resolve_looppart(parts, asspath, context):
asspath = asspath[:]
index = asspath.pop(0)
for part in parts:
- if part is util.YES:
+ if part is util.Uninferable:
continue
# XXX handle __iter__ and log potentially detected errors
if not hasattr(part, 'itered'):
@@ -226,7 +226,7 @@ def _resolve_looppart(parts, asspath, context):
# we achieved to resolved the assignment path,
# don't infer the last part
yield assigned
- elif assigned is util.YES:
+ elif assigned is util.Uninferable:
break
else:
# we are not yet on the last part of the path
@@ -278,7 +278,7 @@ def _arguments_infer_argname(self, name, context):
# arguments information may be missing, in which case we can't do anything
# more
if not (self.args or self.vararg or self.kwarg):
- yield util.YES
+ yield util.Uninferable
return
# first argument of instance/class method
if self.args and getattr(self.args[0], 'name', None) == name:
@@ -307,15 +307,15 @@ def _arguments_infer_argname(self, name, context):
kwarg.parent = self
yield kwarg
return
- # if there is a default value, yield it. And then yield YES to reflect
+ # if there is a default value, yield it. And then yield Uninferable to reflect
# we can't guess given argument value
try:
context = contextmod.copy_context(context)
for inferred in self.default_value(name).infer(context):
yield inferred
- yield util.YES
+ yield util.Uninferable
except exceptions.NoDefault:
- yield util.YES
+ yield util.Uninferable
def arguments_assigned_stmts(self, node, context, asspath=None):
@@ -363,7 +363,7 @@ def _resolve_asspart(parts, asspath, context):
# we achieved to resolved the assignment path, don't infer the
# last part
yield assigned
- elif assigned is util.YES:
+ elif assigned is util.Uninferable:
return
else:
# we are not yet on the last part of the path search on each
@@ -523,11 +523,11 @@ def starred_assigned_stmts(self, node=None, context=None, asspath=None):
try:
rhs = next(value.infer(context))
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
return
- if rhs is util.YES or not hasattr(rhs, 'elts'):
+ if rhs is util.Uninferable or not hasattr(rhs, 'elts'):
# Not interested in inferred values without elts.
- yield util.YES
+ yield util.Uninferable
return
elts = collections.deque(rhs.elts[:])
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index a994392..ab130f5 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -552,7 +552,7 @@ class DictComp(ComprehensionScope):
self.generators = generators
def bool_value(self):
- return util.YES
+ return util.Uninferable
class SetComp(ComprehensionScope):
@@ -573,7 +573,7 @@ class SetComp(ComprehensionScope):
self.generators = generators
def bool_value(self):
- return util.YES
+ return util.Uninferable
class _ListComp(node_classes.NodeNG):
@@ -587,7 +587,7 @@ class _ListComp(node_classes.NodeNG):
self.generators = generators
def bool_value(self):
- return util.YES
+ return util.Uninferable
if six.PY3:
@@ -936,7 +936,7 @@ class FunctionDef(node_classes.Statement, Lambda):
c.hide = True
c.parent = self
class_bases = [next(b.infer(context)) for b in caller.args[1:]]
- c.bases = [base for base in class_bases if base != util.YES]
+ c.bases = [base for base in class_bases if base != util.Uninferable]
c._metaclass = metaclass
yield c
return
@@ -949,7 +949,7 @@ class FunctionDef(node_classes.Statement, Lambda):
for inferred in returnnode.value.infer(context):
yield inferred
except exceptions.InferenceError:
- yield util.YES
+ yield util.Uninferable
def bool_value(self):
return True
@@ -990,7 +990,7 @@ def _is_metaclass(klass, seen=None):
if isinstance(baseobj, bases.Instance):
# not abstract
return False
- if baseobj is util.YES:
+ if baseobj is util.Uninferable:
continue
if baseobj is klass:
continue
@@ -1160,7 +1160,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
isinstance(name_node.value, six.string_types)):
name = name_node.value
else:
- return util.YES
+ return util.Uninferable
result = ClassDef(name, None)
@@ -1170,9 +1170,9 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
result.bases = class_bases.itered()
else:
# There is currently no AST node that can represent an 'unknown'
- # node (YES is not an AST node), therefore we simply return YES here
+ # node (Uninferable is not an AST node), therefore we simply return Uninferable here
# although we know at least the name of the class.
- return util.YES
+ return util.Uninferable
# Get the members of the class
try:
@@ -1343,7 +1343,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
raise exceptions.AttributeInferenceError(target=self, attribute=name,
context=context)
- def instanciate_class(self):
+ def instantiate_class(self):
"""return Instance of ClassDef node, else return self"""
return bases.Instance(self)
@@ -1352,7 +1352,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
This method doesn't look in the instance_attrs dictionary
since it's done by an Instance proxy at inference time. It
- may return a YES object if the attribute has not been actually
+ may return a Uninferable object if the attribute has not been actually
found but a __getattr__ or __getattribute__ method is defined.
If *class_context* is given, then it's considered that the
attribute is accessed from a class context,
@@ -1442,7 +1442,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
try:
for inferred in bases._infer_stmts(self.getattr(name, context),
context, frame=self):
- # yield YES object instead of descriptors when necessary
+ # yield Uninferable object instead of descriptors when necessary
if (not isinstance(inferred, node_classes.Const)
and isinstance(inferred, bases.Instance)):
try:
@@ -1450,13 +1450,13 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
except exceptions.AttributeInferenceError:
yield inferred
else:
- yield util.YES
+ yield util.Uninferable
else:
yield function_to_method(inferred, self)
except exceptions.AttributeInferenceError as error:
if not name.startswith('__') and self.has_dynamic_getattr(context):
- # class handle some dynamic attributes, return a YES object
- yield util.YES
+ # class handle some dynamic attributes, return a Uninferable object
+ yield util.Uninferable
else:
util.reraise(exceptions.InferenceError(
error.message, target=self, attribute=name, context=context))
@@ -1538,7 +1538,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
# Expects this from Py3k TreeRebuilder
try:
return next(node for node in self._metaclass.infer()
- if node is not util.YES)
+ if node is not util.Uninferable)
except (exceptions.InferenceError, StopIteration):
return None
if six.PY3:
@@ -1561,7 +1561,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
inferred = next(assignment.infer())
except exceptions.InferenceError:
return
- if inferred is util.YES: # don't expose this
+ if inferred is util.Uninferable: # don't expose this
return None
return inferred
@@ -1620,7 +1620,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
values = [item[0] for item in slots.items]
else:
values = slots.itered()
- if values is util.YES:
+ if values is util.Uninferable:
continue
if not values:
# Stop the iteration, because the class
@@ -1630,7 +1630,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG,
for elt in values:
try:
for inferred in elt.infer():
- if inferred is util.YES:
+ if inferred is util.Uninferable:
continue
if (not isinstance(inferred, node_classes.Const) or
not isinstance(inferred.value,
diff --git a/astroid/tests/unittest_brain.py b/astroid/tests/unittest_brain.py
index ca47d52..87f4913 100644
--- a/astroid/tests/unittest_brain.py
+++ b/astroid/tests/unittest_brain.py
@@ -119,7 +119,7 @@ class NamedTupleTest(unittest.TestCase):
def foo(fields):
return __(namedtuple("foo", fields))
""")
- self.assertIs(util.YES, next(klass.infer()))
+ self.assertIs(util.Uninferable, next(klass.infer()))
@unittest.skipIf(sys.version_info[0] > 2,
'namedtuple inference is broken on Python 3')
diff --git a/astroid/tests/unittest_builder.py b/astroid/tests/unittest_builder.py
index 485963b..dc161d0 100644
--- a/astroid/tests/unittest_builder.py
+++ b/astroid/tests/unittest_builder.py
@@ -482,7 +482,7 @@ class BuilderTest(unittest.TestCase):
n = test_utils.get_name_node(astroid, 'n')
self.assertIsNot(n.scope(), astroid)
self.assertEqual([i.__class__ for i in n.infer()],
- [util.YES.__class__])
+ [util.Uninferable.__class__])
def test_no_future_imports(self):
mod = builder.parse("import sys")
diff --git a/astroid/tests/unittest_helpers.py b/astroid/tests/unittest_helpers.py
index 6225966..fc95d63 100644
--- a/astroid/tests/unittest_helpers.py
+++ b/astroid/tests/unittest_helpers.py
@@ -154,7 +154,7 @@ class TestHelpers(unittest.TestCase):
from unknown import Unknown
u = Unknown #@
''')
- self.assertEqual(helpers.object_type(node), util.YES)
+ self.assertEqual(helpers.object_type(node), util.Uninferable)
def test_object_type_too_many_types(self):
node = test_utils.extract_node('''
@@ -166,7 +166,7 @@ class TestHelpers(unittest.TestCase):
return 1
test(Unknown) #@
''')
- self.assertEqual(helpers.object_type(node), util.YES)
+ self.assertEqual(helpers.object_type(node), util.Uninferable)
def test_is_subtype(self):
ast_nodes = test_utils.extract_node('''
@@ -216,8 +216,8 @@ class TestHelpers(unittest.TestCase):
class F(D, E): pass #@
''')
self.assertFalse(helpers.is_subtype(cls_e, cls_f))
- self.assertEqual(helpers.is_subtype(cls_f, cls_e), util.YES)
- self.assertEqual(helpers.is_supertype(cls_e, cls_f), util.YES)
+ self.assertEqual(helpers.is_subtype(cls_f, cls_e), util.Uninferable)
+ self.assertEqual(helpers.is_supertype(cls_e, cls_f), util.Uninferable)
self.assertFalse(helpers.is_supertype(cls_f, cls_e))
def test_is_subtype_supertype_unknown_bases(self):
diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py
index 6adaada..19b8377 100644
--- a/astroid/tests/unittest_inference.py
+++ b/astroid/tests/unittest_inference.py
@@ -312,7 +312,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertIsInstance(obj1, nodes.Const)
self.assertEqual(obj1.value, 0)
obj1 = next(inferred)
- self.assertIs(obj1, util.YES, obj1)
+ self.assertIs(obj1, util.Uninferable, obj1)
self.assertRaises(StopIteration, partial(next, inferred))
def test_args_default_inference2(self):
@@ -321,13 +321,13 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertIsInstance(obj1, nodes.Const)
self.assertEqual(obj1.value, 4)
obj1 = next(inferred)
- self.assertIs(obj1, util.YES, obj1)
+ self.assertIs(obj1, util.Uninferable, obj1)
self.assertRaises(StopIteration, partial(next, inferred))
def test_inference_restrictions(self):
inferred = test_utils.get_name_node(self.ast['C']['meth1'], 'arg1').infer()
obj1 = next(inferred)
- self.assertIs(obj1, util.YES, obj1)
+ self.assertIs(obj1, util.Uninferable, obj1)
self.assertRaises(StopIteration, partial(next, inferred))
def test_ancestors_inference(self):
@@ -563,7 +563,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
xxx = ast['xxx']
self.assertSetEqual({n.__class__ for n in xxx.inferred()},
- {nodes.Const, util.YES.__class__})
+ {nodes.Const, util.Uninferable.__class__})
def test_method_argument(self):
code = '''
@@ -579,13 +579,13 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
arg = test_utils.get_name_node(ast['ErudiEntitySchema']['__init__'], 'e_type')
self.assertEqual([n.__class__ for n in arg.infer()],
- [util.YES.__class__])
+ [util.Uninferable.__class__])
arg = test_utils.get_name_node(ast['ErudiEntitySchema']['__init__'], 'kwargs')
self.assertEqual([n.__class__ for n in arg.infer()],
[nodes.Dict])
arg = test_utils.get_name_node(ast['ErudiEntitySchema']['meth'], 'e_type')
self.assertEqual([n.__class__ for n in arg.infer()],
- [util.YES.__class__])
+ [util.Uninferable.__class__])
arg = test_utils.get_name_node(ast['ErudiEntitySchema']['meth'], 'args')
self.assertEqual([n.__class__ for n in arg.infer()],
[nodes.Tuple])
@@ -722,7 +722,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
for node in ast_nodes[:3]:
self.assertRaises(InferenceError, next, node.infer())
for node in ast_nodes[3:]:
- self.assertEqual(next(node.infer()), util.YES)
+ self.assertEqual(next(node.infer()), util.Uninferable)
ast_nodes = test_utils.extract_node('''
[1, 2, 3][None] #@
'lala'['bala'] #@
@@ -971,7 +971,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertEqual(first.value, 43)
second = next(ast_nodes[1].infer())
- self.assertEqual(second, util.YES)
+ self.assertEqual(second, util.Uninferable)
def test_binary_op_other_type_using_reflected_operands(self):
ast_nodes = test_utils.extract_node('''
@@ -982,7 +982,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
1 + A() #@
''')
first = next(ast_nodes[0].infer())
- self.assertEqual(first, util.YES)
+ self.assertEqual(first, util.Uninferable)
second = next(ast_nodes[1].infer())
self.assertIsInstance(second, nodes.Const)
@@ -996,7 +996,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
1 + A() #@
''')
first = next(ast_node.infer())
- self.assertEqual(first, util.YES)
+ self.assertEqual(first, util.Uninferable)
def test_binary_op_list_mul(self):
for code in ('a = [[]] * 2', 'a = 2 * [[]]'):
@@ -1013,10 +1013,10 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = builder.string_build('a = [1] * None\nb = [1] * "r"')
inferred = ast['a'].inferred()
self.assertEqual(len(inferred), 1)
- self.assertEqual(inferred[0], util.YES)
+ self.assertEqual(inferred[0], util.Uninferable)
inferred = ast['b'].inferred()
self.assertEqual(len(inferred), 1)
- self.assertEqual(inferred[0], util.YES)
+ self.assertEqual(inferred[0], util.Uninferable)
def test_binary_op_list_mul_int(self):
'test correct handling on list multiplied by int when there are more than one'
@@ -1088,7 +1088,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
callfuncnode = test_utils.extract_node(code)
inferred = list(callfuncnode.infer())
self.assertEqual(len(inferred), 2, inferred)
- inferred.remove(util.YES)
+ inferred.remove(util.Uninferable)
self.assertIsInstance(inferred[0], nodes.Const)
self.assertIsNone(inferred[0].value)
@@ -1100,7 +1100,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
inferred = list(ast['f'].ilookup('a'))
self.assertEqual(len(inferred), 1)
- self.assertEqual(inferred[0], util.YES)
+ self.assertEqual(inferred[0], util.Uninferable)
def test_nonregr_instance_attrs(self):
"""non regression for instance_attrs infinite loop : pylint / #4"""
@@ -1152,7 +1152,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertTrue(ast.absolute_import_activated(), True)
inferred = next(test_utils.get_name_node(ast, 'import_package_subpackage_module').infer())
# failed to import since absolute_import is activated
- self.assertIs(inferred, util.YES)
+ self.assertIs(inferred, util.Uninferable)
def test_nonregr_absolute_import(self):
ast = resources.build_file('data/absimp/string.py', 'data.absimp.string')
@@ -1270,7 +1270,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
inferred = list(test_utils.get_name_node(ast['foo'], 'spam').infer())
self.assertEqual(len(inferred), 1)
- self.assertIs(inferred[0], util.YES)
+ self.assertIs(inferred[0], util.Uninferable)
def test_nonregr_func_global(self):
code = '''
@@ -1461,7 +1461,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
sub = ast['sub'].inferred()[0]
mul = ast['mul'].inferred()[0]
- self.assertIs(sub, util.YES)
+ self.assertIs(sub, util.Uninferable)
self.assertIsInstance(mul, nodes.Const)
self.assertEqual(mul.value, 42)
@@ -1480,7 +1480,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
sub = ast['sub'].inferred()[0]
mul = ast['mul'].inferred()[0]
- self.assertIs(sub, util. YES)
+ self.assertIs(sub, util. Uninferable)
self.assertIsInstance(mul, nodes.Const)
self.assertEqual(mul.value, 42)
@@ -1500,7 +1500,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
ast = parse(code, __name__)
sub = ast['sub'].inferred()[0]
mul = ast['mul'].inferred()[0]
- self.assertIs(sub, util.YES)
+ self.assertIs(sub, util.Uninferable)
self.assertIsInstance(mul, nodes.List)
self.assertIsInstance(mul.elts[0], nodes.Const)
self.assertEqual(mul.elts[0].value, 42)
@@ -1517,12 +1517,12 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
"""
ast = parse(code, __name__)
node = ast['c']
- self.assertEqual(node.inferred(), [util.YES])
+ self.assertEqual(node.inferred(), [util.Uninferable])
def test_infer_empty_nodes(self):
# Should not crash when trying to infer EmptyNodes.
node = nodes.EmptyNode()
- self.assertEqual(node.inferred(), [util.YES])
+ self.assertEqual(node.inferred(), [util.Uninferable])
def test_infinite_loop_for_decorators(self):
# Issue https://bitbucket.org/logilab/astroid/issue/50
@@ -2016,7 +2016,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
def test_unary_op_leaks_stop_iteration(self):
node = test_utils.extract_node('+[] #@')
- self.assertEqual(util.YES, next(node.infer()))
+ self.assertEqual(util.Uninferable, next(node.infer()))
def test_unary_operands(self):
ast_nodes = test_utils.extract_node('''
@@ -2068,7 +2068,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
for bad_node in ast_nodes[6:]:
inferred = next(bad_node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_unary_op_instance_method_not_callable(self):
ast_node = test_utils.extract_node('''
@@ -2265,11 +2265,11 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
genexpr = next(module['genexpr'].infer())
self.assertTrue(genexpr.bool_value())
dict_comp = next(module['dict_comp'].infer())
- self.assertEqual(dict_comp, util.YES)
+ self.assertEqual(dict_comp, util.Uninferable)
set_comp = next(module['set_comp'].infer())
- self.assertEqual(set_comp, util.YES)
+ self.assertEqual(set_comp, util.Uninferable)
list_comp = next(module['list_comp'].infer())
- self.assertEqual(list_comp, util.YES)
+ self.assertEqual(list_comp, util.Uninferable)
lambda_func = next(module['lambda_func'].infer())
self.assertTrue(lambda_func)
unbound_method = next(module['unbound_method'].infer())
@@ -2283,13 +2283,13 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
bin_op = module['bin_op'].parent.value
self.assertTrue(bin_op.bool_value())
bool_op = module['bool_op'].parent.value
- self.assertEqual(bool_op.bool_value(), util.YES)
+ self.assertEqual(bool_op.bool_value(), util.Uninferable)
callfunc = module['callfunc'].parent.value
- self.assertEqual(callfunc.bool_value(), util.YES)
+ self.assertEqual(callfunc.bool_value(), util.Uninferable)
good_callfunc = next(module['good_callfunc'].infer())
self.assertTrue(good_callfunc.bool_value())
compare = module['compare'].parent.value
- self.assertEqual(compare.bool_value(), util.YES)
+ self.assertEqual(compare.bool_value(), util.Uninferable)
def test_bool_value_instances(self):
instances = test_utils.extract_node('''
@@ -2322,7 +2322,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
AlwaysTrueInstance() #@
ErrorInstance() #@
'''.format(bool=BOOL_SPECIAL_METHOD))
- expected = (False, True, False, True, True, util.YES, util.YES)
+ expected = (False, True, False, True, True, util.Uninferable, util.Uninferable)
for node, expected_value in zip(instances, expected):
inferred = next(node.infer())
self.assertEqual(inferred.bool_value(), expected_value)
@@ -2394,7 +2394,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
A() + B() #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_binop_different_types_reflected_and_normal_not_implemented(self):
node = test_utils.extract_node('''
@@ -2405,7 +2405,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
A() + B() #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_binop_subtype(self):
node = test_utils.extract_node('''
@@ -2438,7 +2438,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
B() + A() #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_binop_supertype(self):
node = test_utils.extract_node('''
@@ -2477,7 +2477,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
A() + B() #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_binop_inferrence_errors(self):
ast_nodes = test_utils.extract_node('''
@@ -2492,7 +2492,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
A() + B() #@
''')
for node in ast_nodes:
- self.assertEqual(next(node.infer()), util.YES)
+ self.assertEqual(next(node.infer()), util.Uninferable)
def test_binop_ambiguity(self):
ast_nodes = test_utils.extract_node('''
@@ -2515,7 +2515,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
C() + A() #@
''')
for node in ast_nodes:
- self.assertEqual(next(node.infer()), util.YES)
+ self.assertEqual(next(node.infer()), util.Uninferable)
def test_bin_op_supertype_more_complicated_example(self):
ast_node = test_utils.extract_node('''
@@ -2544,7 +2544,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
def __add__(self, other): return NotImplemented
A() + A() #@
''')
- self.assertEqual(next(ast_node.infer()), util.YES)
+ self.assertEqual(next(ast_node.infer()), util.Uninferable)
def test_aug_op_same_type_aug_implemented(self):
ast_node = test_utils.extract_node('''
@@ -2579,7 +2579,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
b = B()
b+=A() #@
''')
- self.assertEqual(next(ast_node.infer()), util.YES)
+ self.assertEqual(next(ast_node.infer()), util.Uninferable)
def test_aug_op_subtype_aug_op_is_implemented(self):
ast_node = test_utils.extract_node('''
@@ -2614,7 +2614,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
f = A()
f += B() #@
''')
- self.assertEqual(next(ast_node.infer()), util.YES)
+ self.assertEqual(next(ast_node.infer()), util.Uninferable)
def test_aug_different_types_augop_implemented(self):
ast_node = test_utils.extract_node('''
@@ -2662,7 +2662,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
a = A()
a += B() #@
''')
- self.assertEqual(next(ast_node.infer()), util.YES)
+ self.assertEqual(next(ast_node.infer()), util.Uninferable)
def test_augop_supertypes_not_implemented_returned_for_all(self):
ast_node = test_utils.extract_node('''
@@ -2674,7 +2674,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
a = A()
a += B() #@
''')
- self.assertEqual(next(ast_node.infer()), util.YES)
+ self.assertEqual(next(ast_node.infer()), util.Uninferable)
def test_augop_supertypes_augop_implemented(self):
ast_node = test_utils.extract_node('''
@@ -2746,7 +2746,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
[1, 2, 1, 2])
for rest in ast_nodes[1:]:
inferred = next(rest.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_subscript_supports__index__(self):
ast_nodes = test_utils.extract_node('''
@@ -2915,7 +2915,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
A()[2:] #@
''')
for node in ast_nodes:
- self.assertEqual(next(node.infer()), util.YES)
+ self.assertEqual(next(node.infer()), util.Uninferable)
def test_type__new__with_metaclass(self):
ast_node = test_utils.extract_node('''
@@ -3158,7 +3158,7 @@ class GetattrTest(unittest.TestCase):
for node in ast_nodes[4:]:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES, node)
+ self.assertEqual(inferred, util.Uninferable, node)
def test_attrname_not_string(self):
ast_nodes = test_utils.extract_node('''
@@ -3246,7 +3246,7 @@ class GetattrTest(unittest.TestCase):
getattr(lambda x: x, 'f') #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
class HasattrTest(unittest.TestCase):
@@ -3262,7 +3262,7 @@ class HasattrTest(unittest.TestCase):
''')
for node in ast_nodes:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_attribute_is_missing(self):
ast_nodes = test_utils.extract_node('''
@@ -3305,7 +3305,7 @@ class HasattrTest(unittest.TestCase):
hasattr(lambda x: x, 'f') #@
''')
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
class BoolOpTest(unittest.TestCase):
@@ -3342,7 +3342,7 @@ class BoolOpTest(unittest.TestCase):
''')
for node in ast_nodes:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_other_nodes(self):
ast_nodes = test_utils.extract_node('''
@@ -3422,7 +3422,7 @@ class TestCallable(unittest.TestCase):
''')
for node in ast_nodes:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_not_callable(self):
ast_nodes = test_utils.extract_node('''
@@ -3448,12 +3448,12 @@ class TestBool(unittest.TestCase):
('bool(True)', True),
('bool(False)', False),
('bool(None)', False),
- ('from unknown import Unknown; __(bool(Unknown))', util.YES),
+ ('from unknown import Unknown; __(bool(Unknown))', util.Uninferable),
]
for code, expected in pairs:
node = test_utils.extract_node(code)
inferred = next(node.infer())
- if expected is util.YES:
+ if expected is util.Uninferable:
self.assertEqual(expected, inferred)
else:
self.assertEqual(inferred.value, expected)
@@ -3503,7 +3503,7 @@ class TestBool(unittest.TestCase):
'''.format(method=BOOL_SPECIAL_METHOD))
for node in ast_nodes:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
class TestType(unittest.TestCase):
@@ -3715,7 +3715,7 @@ class ArgumentsTest(unittest.TestCase):
''')
for ast_node in ast_nodes:
inferred = next(ast_node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
def test_fail_to_infer_args(self):
ast_nodes = test_utils.extract_node('''
@@ -3745,7 +3745,7 @@ class ArgumentsTest(unittest.TestCase):
''')
for node in ast_nodes:
inferred = next(node.infer())
- self.assertEqual(inferred, util.YES)
+ self.assertEqual(inferred, util.Uninferable)
class SliceTest(unittest.TestCase):
diff --git a/astroid/tests/unittest_lookup.py b/astroid/tests/unittest_lookup.py
index 7f9c43a..c91acf7 100644
--- a/astroid/tests/unittest_lookup.py
+++ b/astroid/tests/unittest_lookup.py
@@ -172,7 +172,7 @@ class LookupTest(resources.SysPathSetup, unittest.TestCase):
""")
var = astroid.body[1].value
if sys.version_info < (3, 0):
- self.assertEqual(var.inferred(), [util.YES])
+ self.assertEqual(var.inferred(), [util.Uninferable])
else:
self.assertRaises(exceptions.NameInferenceError, var.inferred)
diff --git a/astroid/tests/unittest_nodes.py b/astroid/tests/unittest_nodes.py
index 55c7268..3677bfb 100644
--- a/astroid/tests/unittest_nodes.py
+++ b/astroid/tests/unittest_nodes.py
@@ -359,7 +359,7 @@ from ..cave import wine\n\n"""
method of this From node will be made by unpack_infer.
inference.infer_from will try to import this module, which will fail and
raise a InferenceException (by mixins.do_import_module). The infer_name
- will catch this exception and yield and YES instead.
+ will catch this exception and yield and Uninferable instead.
'''
code = '''
@@ -383,7 +383,7 @@ from ..cave import wine\n\n"""
# present in the other version.
self.assertIsInstance(excs[0], nodes.ClassDef)
self.assertEqual(excs[0].name, 'PickleError')
- self.assertIs(excs[-1], util.YES)
+ self.assertIs(excs[-1], util.Uninferable)
def test_absolute_import(self):
astroid = resources.build_file('data/absimport.py')
diff --git a/astroid/tests/unittest_protocols.py b/astroid/tests/unittest_protocols.py
index 9ba4f6a..6d6bce6 100644
--- a/astroid/tests/unittest_protocols.py
+++ b/astroid/tests/unittest_protocols.py
@@ -67,7 +67,7 @@ class ProtocolTests(unittest.TestCase):
for1_starred = next(assign_stmts.nodes_of_class(Starred))
assigned = next(for1_starred.assigned_stmts())
- self.assertEqual(assigned, util.YES)
+ self.assertEqual(assigned, util.Uninferable)
def _get_starred_stmts(self, code):
assign_stmt = extract_node("{} #@".format(code))
@@ -108,16 +108,16 @@ class ProtocolTests(unittest.TestCase):
@require_version(minver='3.0')
def test_assigned_stmts_starred_yes(self):
# Not something iterable and known
- self._helper_starred_expected("a, *b = range(3) #@", util.YES)
+ self._helper_starred_expected("a, *b = range(3) #@", util.Uninferable)
# Not something inferrable
- self._helper_starred_expected("a, *b = balou() #@", util.YES)
+ self._helper_starred_expected("a, *b = balou() #@", util.Uninferable)
# In function, unknown.
self._helper_starred_expected("""
def test(arg):
- head, *tail = arg #@""", util.YES)
+ head, *tail = arg #@""", util.Uninferable)
# These cases aren't worth supporting.
self._helper_starred_expected(
- "a, (*b, c), d = (1, (2, 3, 4), 5) #@", util.YES)
+ "a, (*b, c), d = (1, (2, 3, 4), 5) #@", util.Uninferable)
@require_version(minver='3.0')
def test_assign_stmts_starred_fails(self):
diff --git a/astroid/tests/unittest_regrtest.py b/astroid/tests/unittest_regrtest.py
index 3e22152..8e60e8a 100644
--- a/astroid/tests/unittest_regrtest.py
+++ b/astroid/tests/unittest_regrtest.py
@@ -251,7 +251,7 @@ def test():
def test_ancestors_yes_in_bases(self):
# Test for issue https://bitbucket.org/logilab/astroid/issue/84
- # This used to crash astroid with a TypeError, because an YES
+ # This used to crash astroid with a TypeError, because an Uninferable
# node was present in the bases
node = extract_node("""
def with_metaclass(meta, *bases):
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index 47807aa..ddfb7a2 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -1132,7 +1132,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
instance = astroid['tgts']
# used to raise "'_Yes' object is not iterable", see
# https://bitbucket.org/logilab/astroid/issue/17
- self.assertEqual(list(instance.infer()), [util.YES])
+ self.assertEqual(list(instance.infer()), [util.Uninferable])
def test_slots(self):
astroid = builder.parse("""
@@ -1372,7 +1372,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
class A(object):
pass
''')
- instance = cls.instanciate_class()
+ instance = cls.instantiate_class()
func = cls.getattr('mro')
self.assertEqual(len(func), 1)
self.assertRaises(AttributeInferenceError, instance.getattr, 'mro')
@@ -1395,7 +1395,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
class B(object): pass
''')
cls = module['B']
- self.assertEqual(util.YES, next(cls.igetattr('foo')))
+ self.assertEqual(util.Uninferable, next(cls.igetattr('foo')))
def test_metaclass_lookup(self):
module = builder.parse('''
diff --git a/astroid/util.py b/astroid/util.py
index 90ea7d6..10c5415 100644
--- a/astroid/util.py
+++ b/astroid/util.py
@@ -33,10 +33,10 @@ def reraise(exception):
@object.__new__
-class YES(object):
+class Uninferable(object):
"""Special inference object, which is returned when inference fails."""
def __repr__(self):
- return 'YES'
+ return 'Uninferable'
def __getattribute__(self, name):
if name == 'next':