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
commitbf8e5410afed79c243466e06c61bc5c994dda00f (patch)
treebf96078792c38f7e24c0b6ba4f3fcde6fe0a3714 /astroid/util.py
parenta1f393ad078ffb050816524a0b20a17cf0d3d838 (diff)
downloadastroid-git-bf8e5410afed79c243466e06c61bc5c994dda00f.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 ceacb124..96ba5fbf 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()