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"}
}
评论列表
文章目录