types.py 文件源码

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

项目:elizabeth-cloud 作者: wemake-services 项目源码 文件源码
def get_field_args(field):
    types = {
        str: graphene.String,
        bool: graphene.Boolean,
        int: graphene.Int,
        float: graphene.Float,
    }

    try:
        args = inspect.signature(field)
        result = {}
        for name, arg in args.parameters.items():
            if arg.default is not None:
                custom_type = types[type(arg.default)]
            else:
                custom_type = graphene.String

            result.update({name: custom_type()})
        return result
    except (KeyError, ValueError):
        return {}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号