summaryrefslogtreecommitdiff
path: root/astroid/util.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-09-26 16:01:30 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-09-26 16:01:30 +0300
commit8b730e92c8fe8a86106b82c77b2adeaefb0ba38b (patch)
tree013f3072e3ab07538ade93b6b799a1c74fb005c4 /astroid/util.py
parent30ae8887189f68494fea3b7889c3bc560d37e7ca (diff)
downloadastroid-8b730e92c8fe8a86106b82c77b2adeaefb0ba38b.tar.gz
Use the object.__new__ decorator to create a singleton instance of the YES object.
Diffstat (limited to 'astroid/util.py')
-rw-r--r--astroid/util.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/astroid/util.py b/astroid/util.py
index ceacb12..96ba5fb 100644
--- a/astroid/util.py
+++ b/astroid/util.py
@@ -30,7 +30,8 @@ def reraise(exception):
six.reraise(type(exception), exception, sys.exc_info()[2])
-class _Yes(object):
+@object.__new__
+class YES(object):
"""Special inference object, which is returned when inference fails."""
def __repr__(self):
return 'YES'
@@ -39,11 +40,8 @@ class _Yes(object):
if name == 'next':
raise AttributeError('next method should not be called')
if name.startswith('__') and name.endswith('__'):
- return super(_Yes, self).__getattribute__(name)
+ return object.__getattribute__(self, name)
return self
def __call__(self, *args, **kwargs):
return self
-
-
-YES = _Yes()