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

Add support for descriptors as model fields #1592

Closed
wants to merge 5 commits into from

Conversation

nickyoung-github
Copy link

@nickyoung-github nickyoung-github commented Dec 23, 2024

Change Summary

Add support for descriptors as model fields. Check newly-introduced __pydantic_descriptor_fields__ to determine whether to get/set fields via __dict__ or __getattribute__/__setattr__

  • Introduce get_model_dict() and set_model_dict(), which get/set descriptor fields which handling __dict__
  • Change get_inner_value() to supplement attrs with descriptor values, if present

Note that this change can be released standalone, but will not on its own enable all the functionality to fix the pydantic/pydantic issue. That also requires this pydantic/pydantic change.

Related issue number

pydantic/pydantic Issue
pydantic/pydantic Pull Request

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

Selected Reviewer: @sydney-runkle

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 68.00000% with 24 lines in your changes missing coverage. Please review.

Project coverage is 89.51%. Comparing base (ab503cb) to head (07beacc).
Report is 265 commits behind head on main.

Files with missing lines Patch % Lines
src/validators/model.rs 70.96% 18 Missing ⚠️
src/serializers/type_serializers/model.rs 53.84% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1592      +/-   ##
==========================================
- Coverage   90.21%   89.51%   -0.71%     
==========================================
  Files         106      112       +6     
  Lines       16339    17916    +1577     
  Branches       36       40       +4     
==========================================
+ Hits        14740    16037    +1297     
- Misses       1592     1859     +267     
- Partials        7       20      +13     
Files with missing lines Coverage Δ
src/serializers/type_serializers/model.rs 91.25% <53.84%> (-2.63%) ⬇️
src/validators/model.rs 91.44% <70.96%> (-6.38%) ⬇️

... and 61 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 562fad3...07beacc. Read the comment docs.

Copy link

codspeed-hq bot commented Dec 23, 2024

CodSpeed Performance Report

Merging #1592 will not alter performance

Comparing nickyoung-github:main (07beacc) with main (562fad3)

Summary

✅ 157 untouched benchmarks

@nickyoung-github
Copy link
Author

Please review

@nickyoung-github
Copy link
Author

This is my first submission attempt for pydantic-core. I've tried to follow all the guidelines but please forgive (and educate!) me if I missed anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Descriptors in Model Fields
2 participants