INNER CODE UNIT · Python

__init__

althonos/pyhmmer · src/pyhmmer/utils.py:55

    def __init__(self, func: typing.Callable[..., _T]) -> None:
        if not callable(func) and not hasattr(func, "__get__"):
            raise TypeError("{!r} is not callable or a descriptor".format(func))
        self.dispatcher = functools.singledispatch(func)
        self.func = func

    @property
    def __isabstractmethod__(self) -> bool:
        return getattr(self.func, "__isabstractmethod__", False)

    def __get__(
        self, obj: _S, cls: typing.Optional[typing.Type[_S]]
    ) -> typing.Callable[..., _T]:
        def _method(*args, **kwargs):  # type: ignore
            method = self.dispatcher.dispatch(args[0].__class__)
            return method.__get__(obj, cls)(*args, **kwargs)

        _method.__isabstractmethod__ = self.__isabstractmethod__  # type: ignore

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…