Repository navigation
Fix serialisation with pydantic 2.14 by not passing info as index_key - #46
Open
hugohills-regnosys wants to merge 1 commit into
Open
hugohills-regnosys wants to merge 1 commit into
hugohills-regnosys wants to merge 1 commit into
Conversation
The wrap serialisers in BaseDataClass and EnumWithMetaMixin passed SerializationInfo as the handler's second positional argument, which is index_key. pydantic 2.14 type-checks it and raises. Fixes finos#45
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #45. With pydantic 2.14, serialising any
BaseDataClassraised'index_key' is expected to be an integer or a string, got 'SerializationInfo(...)'. The wrap serialisers inBaseDataClass._serialize_refsandEnumWithMetaMixin.serialisepassedinfoas the handler's second positional argument, and that argument isindex_key. Both now call the handler with the value only, which is the documented signature, so behaviour on earlier pydantic versions is unchanged.Before this change, 15 tests in this suite failed on pydantic 2.14.1. The enum path had no serialisation test, so this adds
test_dump_annotated_enum_scheme. It fails on 2.14.1 when only the enum call is left unfixed.With this change, the suite gives 218 passed, 1 failed on both pydantic 2.14.1 and 2.13.4. That one failure,
test_init_invalid_directory_or_module, also fails onmainand is unrelated.Separate from this PR: the
pydantic>=2.10.3floor inpyproject.tomlis already broken. On 2.10.3 the package cannot be imported, onmainas well as here, becauseModelWrapValidatorHandlerdoes not exist in that version.🤖 Generated with Claude Code