How to use the pysnooper.pycompat.ABC function in PySnooper

To help you get started, we’ve selected a few PySnooper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexmojaki / snoop / tests / utils.py View on Github external
import pysnooper.pycompat


def get_function_arguments(function, exclude=()):
    try:
        getfullargspec = inspect.getfullargspec
    except AttributeError:
        result = inspect.getargspec(function).args
    else:
        result = getfullargspec(function).args
    for exclude_item in exclude:
        result.remove(exclude_item)
    return result


class _BaseEntry(pysnooper.pycompat.ABC):
    def __init__(self, prefix=''):
        self.prefix = prefix

    @abc.abstractmethod
    def check(self, s):
        pass

    def __repr__(self):
        init_arguments = get_function_arguments(self.__init__,
                                                exclude=('self',))
        attributes = {
            key: repr(getattr(self, key)) for key in init_arguments
                                              if getattr(self, key) is not None
        }
        return '%s(%s)' % (
            type(self).__name__,