pydantic support#253
Open
cjw296 wants to merge 6 commits into
Open
Conversation
Wires up the pydantic optional extra so future Pydantic helpers have a place to land. Floor is pydantic 2.12.0, the first release with Python 3.14 wheels for pydantic-core, so lowest-direct resolution works across the CI matrix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
BaseModel implements __iter__ for dict(model) support, so compare() falls back to sequence comparison on (name, value) tuples instead of doing a proper field-by-field diff. Captured as a sybil-checked doctest in pydantic.rst, motivating a dedicated comparer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds compare_basemodel to testfixtures.pydantic, which uses the model's __dict__ (declared fields only, no pydantic internals) and delegates to _compare_mapping for a clean field-by-field diff. Registers it globally with ignore_eq=True so pydantic's __eq__ — which calls == on field values and breaks on DataFrames — is bypassed automatically. pydantic.rst gains sybil-checked examples: field diff for a simple model and the TypeError a polars-bearing model raises without the registration, contrasted with the clean diff produced with it. comparing.rst replaces the artificial OrmObjBox example with a real-world pydantic BaseModel + pandas DataFrame pair, showing that ignore_eq for the inner type alone is insufficient and that the extras handle it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
No description provided.