diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-08-09 02:06:38 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-08-09 02:06:38 +0300 |
commit | 07d5f4ef7293b8dc27151fc29d99d4a6b772e7be (patch) | |
tree | 348b11e7807cebd9b2bdf45758cf4c2b78fcccde /astroid/util.py | |
parent | 845169b878543fae3d3eeb0a548f013000879457 (diff) | |
download | astroid-git-07d5f4ef7293b8dc27151fc29d99d4a6b772e7be.tar.gz |
Move YES to astroid.util.
YES is needed by other components of astroid, components which aren't
necessarily related to astroid.bases. In order to reduce circular
interdependencies between components, YES is moved into a new module,
tailored for various *utilities*.
Diffstat (limited to 'astroid/util.py')
-rw-r--r-- | astroid/util.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/astroid/util.py b/astroid/util.py new file mode 100644 index 00000000..8dde9b97 --- /dev/null +++ b/astroid/util.py @@ -0,0 +1,38 @@ +# copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr +# +# This file is part of astroid. +# +# astroid is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation, either version 2.1 of the License, or (at your +# option) any later version. +# +# astroid is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License along +# with astroid. If not, see <http://www.gnu.org/licenses/>. +# +# The code in this file was originally part of logilab-common, licensed under +# the same license. + +class _Yes(object): + """Special inference object, which is returned when inference fails.""" + def __repr__(self): + return 'YES' + + def __getattribute__(self, name): + if name == 'next': + raise AttributeError('next method should not be called') + if name.startswith('__') and name.endswith('__'): + return super(_Yes, self).__getattribute__(name) + return self + + def __call__(self, *args, **kwargs): + return self + + +YES = _Yes() |