agentsclimarketplace

Pydantic

Skill jiatastic/open-python-skills/skills/pydantic

Pydantic models and validation. Use when: (1) Defining schemas, (2) Validating input/output, (3) Generating JSON schema.From its SKILL.md

Install
npx -y skills add jiatastic/open-python-skills --skill pydantic

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
  • runs commandsInstructs the agent to run 1 command, including `uv pip install pydantic`.

SKILL.md

1.6 KB, 353 tokens by cl100k_base, as published. Nobody here has run it

pydantic

Type-driven validation and serialization using Pydantic models.

Overview

Pydantic validates data using Python type hints and provides rich serialization via model_dump() and JSON schema output.

When to Use

  • Validating request/response payloads
  • Normalizing untrusted input
  • Generating JSON schema for docs

Quick Start

uv pip install pydantic
from pydantic import BaseModel

class User(BaseModel):
    id: int
    email: str

user = User(id=1, email="[email protected]")

Core Patterns

  1. Typed fields: strict schema definitions.
  2. Field validators: custom validation logic.
  3. Model validators: cross-field checks.
  4. Serialization: model_dump() and model_dump_json().
  5. Settings: environment-driven config via BaseSettings.

Example: field_validator

from pydantic import BaseModel, field_validator

class Model(BaseModel):
    name: str

    @field_validator("name")
    @classmethod
    def ensure_not_empty(cls, v: str):
        if not v:
            raise ValueError("name required")
        return v

Example: model_validate + model_dump

from pydantic import BaseModel

class Model(BaseModel):
    foo: int

model = Model.model_validate({"foo": 1})
print(model.model_dump())

Troubleshooting

  • Coercion surprises: use strict types if needed
  • Slow validators: keep them minimal
  • Mutable defaults: use default_factory

References

What ships with it: 2 files

1.0 KB alongside SKILL.md

references/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.