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

Pydantic v2 support for MSONable types #548

Merged
merged 12 commits into from
Sep 5, 2023

Conversation

munrojm
Copy link
Contributor

@munrojm munrojm commented Aug 30, 2023

Summary

This PR adds support for pydantic >= 2.0 with the addition of custom class validation methods to MSONable:

  • __get_pydantic_json_schema__ to define pydantic field JSON schema
  • __get_pydantic_core_schema__ to define pydantic field core schema

The same validation function is used for both versions.

@munrojm munrojm changed the title Pydantic v2 support for MSONable types [WIP] Pydantic v2 support for MSONable types Aug 30, 2023
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage: 75.75% and project coverage change: -0.04% ⚠️

Comparison is base (b7460a1) 76.57% compared to head (6a56a6f) 76.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #548      +/-   ##
==========================================
- Coverage   76.57%   76.53%   -0.04%     
==========================================
  Files          27       27              
  Lines        1524     1547      +23     
  Branches      320      322       +2     
==========================================
+ Hits         1167     1184      +17     
- Misses        297      303       +6     
  Partials       60       60              
Files Changed Coverage Δ
monty/json.py 85.88% <75.75%> (-0.89%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@munrojm munrojm changed the title [WIP] Pydantic v2 support for MSONable types Pydantic v2 support for MSONable types Aug 31, 2023
@Andrew-S-Rosen
Copy link
Contributor

Thanks, @munrojm! Very much looking forward to getting this merged. I'm not sure how picky @shyuep is with the codecov tests, but you're super close to the diff hit so if you need to you can probably add another test to get the lovely green check :)

@shyuep
Copy link
Contributor

shyuep commented Sep 5, 2023

Merged. The codecov is just meant to check if something really has no tests. Here we are well covered.

@Andrew-S-Rosen
Copy link
Contributor

Andrew-S-Rosen commented Sep 5, 2023

Great, thanks! Would you mind minting a new release whenever you get a moment?

@shyuep
Copy link
Contributor

shyuep commented Sep 5, 2023

Already done.

@Andrew-S-Rosen
Copy link
Contributor

Beautiful!

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.

3 participants