signature.py 文件源码

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

项目:mockito-python 作者: kaste 项目源码 文件源码
def get_signature(obj, method_name):
    method = getattr(obj, method_name)

    # Eat self for unbound methods bc signature doesn't do it
    if PY3:
        if (inspect.isclass(obj) and
                not inspect.ismethod(method) and
                not isinstance(
                    obj.__dict__.get(method_name),
                    staticmethod)):
            method = functools.partial(method, None)
    else:
        if (isinstance(method, types.UnboundMethodType) and
                method.__self__ is None):
            method = functools.partial(method, None)

    try:
        return signature(method)
    except:
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号