Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Old branch) Feature: Pydantic V2 support #14

Closed
wants to merge 5 commits into from

Conversation

NowanIlfideme
Copy link
Owner

@NowanIlfideme NowanIlfideme commented Apr 26, 2023

Trying to add support for Pydantic V2.

Currently, it's impossible, as Pydantic doesn't support cusom encoders for JSON (or any other type). Or at least I couldn't figure out how to add it; it's referenced in docs.

Related issues/discussions in Pydantic:

Main discussion - pydantic/pydantic#4456

Apparently, serialization is already implemented here? - pydantic/pydantic#4739 - but I can't find any documentation, and I can't find it in the Python interface code for pydantic-core.

V1 JSON Encoder issue/discussion - pydantic/pydantic#2277

Closes #15 when merged.

@NowanIlfideme NowanIlfideme self-assigned this Apr 26, 2023
@NowanIlfideme
Copy link
Owner Author

JSON/YAML dumping of simple models still work in V2, but not the trickery done for serializing the fields with arbitrary types.

As I understand, V2 will switch to using "field serializers", rather than allowing json_encoders. This might make it easier to apply models with custom types in general, but you'd need to apply how to encode them to each model. Anyways, this will have to wait until it's more clear from Pydantic's side.

@NowanIlfideme NowanIlfideme changed the title Feature: Pydantic V2 support (Old branch) Feature: Pydantic V2 support Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Pydantic V2
1 participant