INNER CODE UNIT · Python
singledispatchmethod
althonos/pyhmmer · src/pyhmmer/utils.py:46
class singledispatchmethod(typing.Generic[_T]):
"""Single-dispatch generic method descriptor.
Backported from Python 3.8 to support older Python versions. Additional
type annotations were obtained from the `functools` stubs in the Python
`typeshed <https://github.com/python/typeshed>`_ repository.
"""
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)