diff options
author | Ceridwen <ceridwenv@gmail.com> | 2015-11-06 18:06:45 -0500 |
---|---|---|
committer | Ceridwen <ceridwenv@gmail.com> | 2015-11-06 18:06:45 -0500 |
commit | cc7ea53df2383cd188e2b0958b231e1eb70fc79c (patch) | |
tree | a8170ee5867f49721c3d071c322ef3815cc608b9 /astroid/inference.py | |
parent | 67dc5fda9c487bbbe6b3ac1e98af76b63d13396e (diff) | |
download | astroid-cc7ea53df2383cd188e2b0958b231e1eb70fc79c.tar.gz |
Rename Uninferable and instatiate_class
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 76 |
1 files changed, 38 insertions, 38 deletions
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 |