You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working a Starlette project that uses Pydantic v2. I'd be interested in trying out cacheme, but the conflicting Pydantic version requirements make it impossible. Two obvious options present themselves:
Make pydantic support optional (perhaps allow customization of object_encoder/object_decoder on the Serialization classes, with the default being an identity function for accepting/returning primitive types.
Thank you for considering this.
The text was updated successfully, but these errors were encountered:
@Yiling-J you have done a good job, nice lib, but sincerely we need to update it to pydantic v2
Please leave a comment below if you need help or contribution in migration
@eykd@aspatari Sorry for no replying because I miss the notification when this issue was opened (seems I didn't even receive it). I'm not very familiar with Pydantic and haven't been using Python recently. It would be greatly appreciated if you could help @aspatari. but if you're busy I can certainly take a look into it myself.
@eykd@aspatari After reading the Pydantic documentation a bit, I think it might be better to remove the serializer concept altogether and instead adding dumps and loads methods directly to the Node class:
If the user hasn't overridden dumps and loads, and the Node object inherits from Pydantic BaseModel or is Pydantic dataclass, using Pydantic's built-in methods.
If the user hasn't overridden dumps and loads, and the Node object is a Python dataclass, Pydantic's TypeAdapter could be used. It requires a class as an input parameter, implementing these methods on Node resolves this.
If the user hasn't overridden dumps and loads, and the Node object is a arbitrary Python object, using pickle instead.
If the user has overridden dumps and loads, just use them.
Considering that cacheme isn't widely adopted (13 downloads last week), I think removing the serializer won't introduce any significant issues.
I'm working a Starlette project that uses Pydantic v2. I'd be interested in trying out cacheme, but the conflicting Pydantic version requirements make it impossible. Two obvious options present themselves:
object_encoder
/object_decoder
on the Serialization classes, with the default being an identity function for accepting/returning primitive types.Thank you for considering this.
The text was updated successfully, but these errors were encountered: