r/pydantic • u/Sea-Boysenberry-6984 • 13h ago
[Showcase] Pydantic Views: derive operation-specific schemas from one model
r/pydantic • u/Sea-Boysenberry-6984 • 13h ago
r/pydantic • u/louisbsc • 22d ago
Pydantic validation V3 is in the works. A lot of people went through the V1 to V2 migration, and we know it wasn’t easy. The team is working to make sure this one is much less painful.
So here’s a commitment: every breaking change in V3 will be one of the following
a correctness fix, such as a bug that affects a minority of users
a change where you can easily opt back in to the previous behaviour
If you’re using Pydantic in production and would rather talk to a Pydantic engineer to plan the migration, we’re also launching Enterprise support for exactly that.
Blogpost with the full story: https://pydantic.dev/articles/pydantic-validation-next-steps
Happy to answer questions in the comments.
r/pydantic • u/Equivalent-Task8081 • Oct 08 '26
I built pcode, an MIT-licensed terminal coding agent built on Pydantic AI. Sharing it here as a Pydantic AI ecosystem project, rather than a data-validation library.
Its extension interface uses Pydantic AI capabilities: Python files can add tools, slash commands, guardrails and sub-agents. The application builds on Pydantic AI's Harness coder and adds terminal interaction, saved conversations, browser automation with your existing logins, background jobs and worktree-based sessions.
One UI detail is native terminal scrollback whose detail level can change after a turn finishes. Commands, output and diffs can be shown or hidden without rerunning anything; ordinary terminal scrolling, search and copy still work. You can also rewind and branch conversations, customize keybindings or use Vim editing, and inspect changes in a diff popup.
Long-running commands can continue as background jobs and wake the agent on completion. Separate git worktrees support parallel sessions. It works with existing Claude/ChatGPT subscriptions or API keys; model access is separate from the open-source application. It edits files and runs shell commands with your permissions and no approval prompt, so read the tool-permissions documentation first.
Code, screenshots and documentation: https://github.com/cruxwell/pcode
r/pydantic • u/ANautyWolf • Sep 05 '26
These are pictures of the classes and the given error. I am trying to make the trigger class accept different potential cargo filter classes. The trigger class should be agnostic towards the cargo filter classes. All the trigger class really needs is the __str__ method. What am I doing wrong? I’ve tried using the type statement and a union and both give me the same error.
Any help would be greatly appreciated.
Edit: Turns out the imports were different for each file. Changing them to the same imports made the errors go away.
r/pydantic • u/louisbsc • Aug 31 '26
Hey everyone! I'm u/louisbsc, a moderator of r/pydantic.
This is our new home for all things related to Pydantic data validation, Pydantic AI, Pydantic Logfire, and HTTPX2. We're excited to have you join us!
What to Post
Post anything that you think the community would find interesting, helpful, or inspiring. Feel free to share your thoughts, photos, or questions about AI, agents, BaseModels, capabilities, observability, tracing, or anything else you think could be useful.
Community Vibe
We're all about being friendly, constructive, and inclusive. Let's build a space where everyone feels comfortable sharing and connecting.
How to Get Started
Introduce yourself in the comments below.
Post something today! Even a simple question can spark a great conversation.
If you know someone who would love this community, invite them to join.
Thanks for being part of the very first wave. Together, let's make r/pydantic amazing.
r/pydantic • u/ANautyWolf • Aug 20 '26
I am trying to create list subclasses that only take particular classes. These lists can be appended to and the like but each time the list is changed the item is checked to see whether it is the same class as the rest of the list.
The list methods that are overwritten are:
- __init__
- __set_item__
- __str__
- append
- extend
- insert
Each one runs through a validate_member method before changing the list.
As an example, I want to make a list subclass called Course that only takes Pydantic extra types Coordinate values. I want this list subclass to be a valid BaseModel attribute.
Right now I’m having to use a field_validator for every class that Course and the other lists are in which feels redundant, unpythonic, and is a pain to have to do every time. I am having to do so because it says something about arbitrary types.
I was wondering if someone might have some advice.
r/pydantic • u/type-hinter • Aug 14 '26
r/pydantic • u/louisbsc • Aug 12 '26
Monty is an open-source, minimal Python interpreter written in Rust (github.com/pydantic/monty). Startup is measured in microseconds, and it inverts the usual sandbox model: it starts from nothing and only exposes the functions you explicitly hand it.
We're running a $20,000 bounty (with Prefect and Hugging Face Face) for anyone who can escape the sandbox and read a secret off the server running it.
What changed since the last round: Monty now runs in a subprocess behind a WebSocket service over a protobuf wire protocol, so old REST-era approaches don't carry over. There's also a new mount feature that lets Monty read a directory on the client machine, and a separate bounty for escaping it.
Nobody escaped the last round. Round 1 fell to a use-after-free in under 48 hours.
This is (probably) the last round before we tag Monty V1, so it's your last crack at the interpreter as it stands.
Full rules: https://pydantic.dev/monty
Happy to talk about the interpreter internals or the sandbox model in the comments.
r/pydantic • u/louisbsc • Aug 06 '26
r/pydantic • u/louisbsc • Aug 06 '26
this place has has been quiet for a while, let's fix that. I work on Pydantic and I'm going to start posting here regularly: tips, new features, things I see people get wrong, community questions.
What would you like to see here?
r/pydantic • u/[deleted] • Sep 04 '24
Hi, I have a model that contains a dict of sub models. However the values of the dict are heterogeneous. I can’t simply create a discriminated union because I don’t know what models will be in the union until it’s running.
It seems like I should be able to do this with a root model and a type adapter, but it’s not clear how. Do I need a custom validator on my root model to call validate_Python from? Or can I just reference the type adapter directly from the signature of the root model somehow?
If I need a validator also, which one?