Skip to content

pydantic support#253

Open
cjw296 wants to merge 6 commits into
mainfrom
pydantic/human
Open

pydantic support#253
cjw296 wants to merge 6 commits into
mainfrom
pydantic/human

Conversation

@cjw296

@cjw296 cjw296 commented Jul 1, 2026

Copy link
Copy Markdown
Member

No description provided.

cjw296 and others added 6 commits July 1, 2026 11:03
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>
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.

1 participant