-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
Description
Many APIs use something like {"success": true, data: ...}
.
It will be really nice to be able to validate such boolean field against constant value when deserializing:
from typing import Literal
import msgspec
class ResponseData(msgspec.Struct):
pass
class Response(msgspec.Struct):
success: Literal[True]
data: ResponseData
response = msgspec.convert(
{
"success": True,
"data": {},
},
Response,
)
At the moment this raises:
TypeError: Literal may only contain None/integers/strings - typing.Literal[True] is not supported
Thank you 👍
beauxq, HansBrende, q0w, saladware and woodruffw
Metadata
Metadata
Assignees
Labels
No labels