summaryrefslogtreecommitdiff
path: root/astroid/inference.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-12-30 15:42:50 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2016-12-30 15:42:50 +0200
commite37acdc4bfe7e0d714e86a5c7f5d9f956cef15e5 (patch)
tree78fcf64c6af0d874ff9476d18e975efcd442c4d4 /astroid/inference.py
parent47779406d852d1951078e169a7210b533f7e2d03 (diff)
downloadastroid-git-e37acdc4bfe7e0d714e86a5c7f5d9f956cef15e5.tar.gz
Add a new mechanism for retrieving the special methods.
Diffstat (limited to 'astroid/inference.py')
-rw-r--r--astroid/inference.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/astroid/inference.py b/astroid/inference.py
index a5780682..4e46b4e1 100644
--- a/astroid/inference.py
+++ b/astroid/inference.py
@@ -20,6 +20,7 @@ from astroid import decorators
from astroid import exceptions
from astroid.interpreter import runtimeabc
from astroid.interpreter import util as inferenceutil
+from astroid.interpreter import dunder_lookup
from astroid import protocols
from astroid.tree import treeabc
from astroid import util
@@ -370,7 +371,13 @@ def infer_unaryop(self, context=None, nodes=None):
continue
try:
- meth = operand.getattr(meth, context=context)[0]
+ try:
+ methods = dunder_lookup.lookup(operand, meth)
+ except exceptions.NotSupportedError:
+ yield util.BadUnaryOperationMessage(operand, self.op, exc)
+ continue
+
+ meth = methods[0]
inferred = next(meth.infer(context=context))
if inferred is util.Uninferable or not inferred.callable():
continue