19 September 2025
Pandaaaa Yippython pydantic 有没有办法做类似这种操作?
CustomType: typing.TypeAlias = Annotated[
T,
BeforeValidator(validate_func),
]
这样?
Johnnnnnnny讲真我没理解你想实现什么功能
定义一个CustomType类型,默认某种类型(GenericValue),但是如果给定另外一个类型给CustomType,例如CustomType[int],它就用int作为Annoated的类型