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

Support serialization mode specification from model config and SerializationConfig #1122

Merged
merged 12 commits into from
Jan 9, 2024

Conversation

sydney-runkle
Copy link
Member

@sydney-runkle sydney-runkle commented Dec 14, 2023

Change Summary

  • Standardize shared code across various serialization mode enums
  • Ensure serialization config settings are respected when specified on a model, but not when creating SchemaSerializer
  • Support inf_nan_mode in the to_json and to_jsonable_python calls

Related issue number

Fix pydantic/pydantic#8214

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Merging #1122 (5d607c4) into main (bec63db) will increase coverage by 0.14%.
Report is 17 commits behind head on main.
The diff coverage is 92.53%.

❗ Current head 5d607c4 differs from pull request most recent head 4317f2e. Consider uploading reports for the commit 4317f2e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1122      +/-   ##
==========================================
+ Coverage   89.73%   89.88%   +0.14%     
==========================================
  Files         106      106              
  Lines       16380    16436      +56     
  Branches       35       35              
==========================================
+ Hits        14699    14773      +74     
+ Misses       1674     1656      -18     
  Partials        7        7              
Files Coverage Δ
src/errors/validation_exception.rs 92.95% <100.00%> (+1.17%) ⬆️
src/serializers/extra.rs 99.08% <100.00%> (ø)
src/serializers/mod.rs 99.53% <100.00%> (+<0.01%) ⬆️
src/serializers/type_serializers/bytes.rs 100.00% <100.00%> (ø)
src/serializers/type_serializers/timedelta.rs 97.87% <100.00%> (-0.17%) ⬇️
src/serializers/infer.rs 94.80% <83.33%> (-0.21%) ⬇️
src/serializers/config.rs 95.49% <89.47%> (+6.60%) ⬆️

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bec63db...4317f2e. Read the comment docs.

Copy link

codspeed-hq bot commented Dec 14, 2023

CodSpeed Performance Report

Merging #1122 will degrade performances by 14.58%

Comparing fix-ser-json-bytes (4317f2e) with main (bec63db)

Summary

⚡ 4 improvements
❌ 1 regressions
✅ 135 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main fix-ser-json-bytes Change
test_small_class_core_model 58 µs 50.2 µs +15.5%
test_core_future_str 39.3 µs 31 µs +26.65%
test_core_future 46.7 µs 54.7 µs -14.58%
test_core_str 39 µs 30.6 µs +27.4%
test_core_future 37.6 µs 29 µs +29.71%

@sydney-runkle sydney-runkle marked this pull request as ready for review December 14, 2023 20:14
@sydney-runkle sydney-runkle changed the title Draft: support ser_json_bytes from model config and SerializationConfig Support serialization mode specification from model config and SerializationConfig Dec 14, 2023
tests/serializers/test_bytes.py Show resolved Hide resolved
src/serializers/infer.rs Outdated Show resolved Hide resolved
python/pydantic_core/_pydantic_core.pyi Outdated Show resolved Hide resolved
Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one final nit!

src/serializers/config.rs Outdated Show resolved Hide resolved
src/serializers/config.rs Show resolved Hide resolved
@sydney-runkle sydney-runkle merged commit e3ae7f6 into main Jan 9, 2024
26 of 27 checks passed
@sydney-runkle sydney-runkle deleted the fix-ser-json-bytes branch January 9, 2024 03:03
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.

TypeAdapter containing Annotated model does not use ser_json_bytes setting
2 participants