diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-09-26 16:01:30 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-09-26 16:01:30 +0300 |
commit | 8b730e92c8fe8a86106b82c77b2adeaefb0ba38b (patch) | |
tree | 013f3072e3ab07538ade93b6b799a1c74fb005c4 /astroid/util.py | |
parent | 30ae8887189f68494fea3b7889c3bc560d37e7ca (diff) | |
download | astroid-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.py | 8 |
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() |