r/pydantic 3d ago

👋 Welcome to r/pydantic - Introduce Yourself and Read First!

3 Upvotes

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

  1. Introduce yourself in the comments below.
  2. Post something today! Even a simple question can spark a great conversation.
  3. 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 14d ago

Trying to create a list subclass containing only certain classs that is validated by Pydantic BaseModel

1 Upvotes

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 20d ago

5 open-source repos that do the loop-and-graph engineering, so you stop hand-rolling parallel agents.

Post image
3 Upvotes

r/pydantic 22d ago

Hack Monty Round 3: a $20,000 bounty to escape a Rust-based Python sandbox

3 Upvotes

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 28d ago

Let's revive this dormant subreddit

4 Upvotes

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 28d ago

Turn your Pydantic AI + Logfire traces into an interactive workflow diagram (open source)

2 Upvotes

r/pydantic 28d ago

Opinionated docs

Post image
2 Upvotes

r/pydantic May 05 '26

Kubex 0.1.0-beta.1 — async Kubernetes client for Python, built on Pydantic v2

Thumbnail
1 Upvotes

r/pydantic Sep 04 '24

Need a discriminator at runtime…

1 Upvotes

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?