diff options
author | Florian Bruhin <me@the-compiler.org> | 2015-07-26 11:51:04 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2015-07-26 11:51:04 +0200 |
commit | ce399f468335bf2370bccb80ee292bd33100fb84 (patch) | |
tree | 0ada94f46bac78a8f10923b7a1af0cb71cde9ad6 /pylint/interfaces.py | |
parent | 20fa6d19bb11b833e41a0489c325178f878ac479 (diff) | |
download | pylint-git-ce399f468335bf2370bccb80ee292bd33100fb84.tar.gz |
Get rid of logilab.common.interface.
--HG--
branch : no-logilab-common
Diffstat (limited to 'pylint/interfaces.py')
-rw-r--r-- | pylint/interfaces.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pylint/interfaces.py b/pylint/interfaces.py index 64f5a9561..03fe1df4a 100644 --- a/pylint/interfaces.py +++ b/pylint/interfaces.py @@ -13,8 +13,6 @@ """Interfaces for Pylint objects""" from collections import namedtuple -from logilab.common.interface import Interface - Confidence = namedtuple('Confidence', ['name', 'description']) # Warning Certainties HIGH = Confidence('HIGH', 'No false positive possible.') @@ -27,6 +25,26 @@ UNDEFINED = Confidence('UNDEFINED', CONFIDENCE_LEVELS = [HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED] +class Interface(object): + """Base class for interfaces.""" + def is_implemented_by(cls, instance): + return implements(instance, cls) + is_implemented_by = classmethod(is_implemented_by) + + +def implements(obj, interface): + """Return true if the give object (maybe an instance or class) implements + the interface. + """ + kimplements = getattr(obj, '__implements__', ()) + if not isinstance(kimplements, (list, tuple)): + kimplements = (kimplements,) + for implementedinterface in kimplements: + if issubclass(implementedinterface, interface): + return True + return False + + class IChecker(Interface): """This is an base interface, not designed to be used elsewhere than for sub interfaces definition. |