Generate avro schemas from python dataclasses, Pydantic models and Faust Records. Code generation from avro schemas. Serialize/Deserialize python instances with avro schemas.
Add a new way to generate Avro schema and serialize custom fields for Pydantic v2 AvroBaseModels. This new strategy provides a CustomAvroEncoder class to use as an annotation on fields with types that don't natively support serialization to Avro. The existing Pydantic v2 custom serialization/schema-generation strategy depends on the json_encoders model config, which is deprecated.
My only usecase for this is so I can serialize timedeltas to float seconds in my models without having to depend on deprecated Pydantic functionality (and without having to write a custom __get_pydantic_core_schema__, because this is natively supported by Pydantic). If there's a better way to do this that I missed, please let me know (and thank you for your time)!
Add a new way to generate Avro schema and serialize custom fields for Pydantic v2
AvroBaseModel
s. This new strategy provides aCustomAvroEncoder
class to use as an annotation on fields with types that don't natively support serialization to Avro. The existing Pydantic v2 custom serialization/schema-generation strategy depends on thejson_encoders
model config, which is deprecated.My only usecase for this is so I can serialize
timedelta
s tofloat
seconds in my models without having to depend on deprecated Pydantic functionality (and without having to write a custom__get_pydantic_core_schema__
, because this is natively supported by Pydantic). If there's a better way to do this that I missed, please let me know (and thank you for your time)!