click_helper.py 文件源码

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

项目:temci 作者: parttimenerd 项目源码 文件源码
def validate(type_scheme: Type) -> t.Callable[[click.Context, str, t.Any], t.Any]:
    """
    Creates a valid click option validator function that can be passed to click via the callback
    parameter.
    The validator function expects the type of the value to be the raw type of the type scheme.

    :param type_scheme: type scheme the validator validates against
    :return: the validator function
    """
    def func(ctx, param, value):
        param = param.human_readable_name
        param = param.replace("-", "")
        res = verbose_isinstance(value, type_scheme, value_name=param)
        if not res:
            raise click.BadParameter(str(res))
        return value
    return func
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号