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 👍
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:
At the moment this raises:
Thank you 👍