twitch_api.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:twlived 作者: tausackhn 项目源码 文件源码
def method_dispatch(func: Callable[..., T]) -> Callable[..., T]:
    """
    Single-dispatch class method decorator
    Works like functools.singledispatch for none-static class methods.
    """
    dispatcher = functools.singledispatch(func)

    @functools.wraps(func)
    def wrapper(*args: Any, **_: Any) -> T:
        return dispatcher.dispatch(args[1].__class__)(*args, **_)

    # issue: https://github.com/python/mypy/issues/708
    wrapper.register = dispatcher.register  # type: ignore
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号