test_typing.py 文件源码

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

项目:jsonschema-extractor 作者: toumorokoshi 项目源码 文件源码
def test_typing_extractor_register(typing_extractor):

    def extract_set(extractor, typ):
        subtype = Any
        if typ.__args__ and typ.__args__[0] is not Any:
            subtype = typ.__args__[0]
        return {
            "type": "array",
            "title": "set",
            "items": extractor.extract(extractor, subtype)
        }

    typing_extractor.register(set, extract_set)

    assert typing_extractor.extract(typing_extractor, Set[int]) == {
        "type": "array",
        "title": "set",
        "items": {"type": "integer"}
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号