-
Notifications
You must be signed in to change notification settings - Fork 250
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 SchemaSerializer.__reduce__
method to enable pickle
serialization
#1006
Merged
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a1c6164
Add __reduce__ method to SchemaSerializer
edoakes ce155b8
Revert changes to _pydantic_core.pyi
edoakes 3159084
Fix constructor in tests
edoakes cdc32a2
Handle Option in __traverse__
edoakes bba95d8
Make the linter happy
edoakes 24ad5b0
Add test_pickling.py
edoakes bdafefd
Fix imports
edoakes 8c41c88
Fix imports
edoakes 70f3032
Fix lint
edoakes 8b8bfd5
Add config to gc.collect() test
edoakes 661ac07
Fix lint
edoakes 3e9b372
Use slf.get_type()
edoakes 9ef470b
Update validator __reduce__ to include config
edoakes 26cb67a
Fix config test
edoakes ed3ad18
Fix tests
edoakes e11ba19
Revert small type change
edoakes 6cbba7b
Merge branch 'main' of https://github.com/pydantic/pydantic-core into…
edoakes 1d17408
Add config to gc test
edoakes 722bbdf
small nit
edoakes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my take:
You'll need to update the
#[pyclass]
definition above forSchemaSerializer
to include#[pyclass(frozen)]
.Justifications:
slf: &PyCell<Self>
is equivalent toself
Python objectslf.get()
gives read access to the Rust data as long as it'sfrozen
type(self)
rather than hard-codeSchemaSerializer
type in case we allow subclassing later.slf.get_type()
is a cleaner way to do it than trying to usegetattr
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the pointers, I'll update!