diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-08-13 18:07:11 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-08-13 18:07:11 +0300 |
commit | d8b19eae5e855b5453f399858aadeb7cf218ee70 (patch) | |
tree | 8361c6365dce7f5ccbbc50afff201b400c0af115 /inference.py | |
parent | 52ae161026cdc83721d5c4af7d34a9f9131966f7 (diff) | |
download | astroid-git-d8b19eae5e855b5453f399858aadeb7cf218ee70.tar.gz |
The inference engine handles binary operations (add, mul etc.) between instances.
Diffstat (limited to 'inference.py')
-rw-r--r-- | inference.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/inference.py b/inference.py index c36f6958..4186307a 100644 --- a/inference.py +++ b/inference.py @@ -30,7 +30,9 @@ from astroid.exceptions import (AstroidError, InferenceError, NoDefault, from astroid.bases import (YES, Instance, InferenceContext, _infer_stmts, copy_context, path_wrapper, raise_if_nothing_infered) -from astroid.protocols import _arguments_infer_argname +from astroid.protocols import ( + _arguments_infer_argname, + BIN_OP_METHOD, UNARY_OP_METHOD) MANAGER = AstroidManager() @@ -292,13 +294,6 @@ def infer_subscript(self, context=None): nodes.Subscript._infer = path_wrapper(infer_subscript) nodes.Subscript.infer_lhs = raise_if_nothing_infered(infer_subscript) - -UNARY_OP_METHOD = {'+': '__pos__', - '-': '__neg__', - '~': '__invert__', - 'not': None, # XXX not '__nonzero__' - } - def infer_unaryop(self, context=None): for operand in self.operand.infer(context): try: @@ -321,21 +316,6 @@ def infer_unaryop(self, context=None): yield YES nodes.UnaryOp._infer = path_wrapper(infer_unaryop) - -BIN_OP_METHOD = {'+': '__add__', - '-': '__sub__', - '/': '__div__', - '//': '__floordiv__', - '*': '__mul__', - '**': '__power__', - '%': '__mod__', - '&': '__and__', - '|': '__or__', - '^': '__xor__', - '<<': '__lshift__', - '>>': '__rshift__', - } - def _infer_binop(operator, operand1, operand2, context, failures=None): if operand1 is YES: yield operand1 |