I want to create a custom Pydantic type for Python’s ElementTree
. It should accept string as input and type to parse the XML string via ElementTree.fromstring
and raise appropriate error is invalid XML is found.
I tried creating a custom type using pydantic Annotated
method but got an error saying ElementTree.Element
does not define __get_pydantic_core_schema__
.