pydantic-partial
Create partial models from your pydantic models. Partial models may allow None for certain or all fields.
What it is and what it does
pydantic-partial is a mixin and utility library that generates optional variants of pydantic models. It lets you take a normal pydantic BaseModel and create a version where all fields, or just selected ones, become optional and accept None values. This is particularly useful for API endpoints handling PATCH requests, where clients only send fields they want to update, or for response DTOs where you want to omit certain fields without validation errors.
The library provides two main interfaces: a PartialModelMixin you can inherit from, and a standalone create_partial_model() function for models you don't control. It also supports recursive partials for nested model structures. The tradeoff is that type checkers cannot see the optionality changes—partial models appear to type checkers as identical to their originals—so the library is best suited for API data-transfer scenarios rather than complex type-aware logic.
Use it for:
- Handle PATCH HTTP requests where only some fields are provided and should not trigger validation errors for missing required fields.
- Create response DTOs that omit certain fields without raising validation errors when combined with exclude_none.
- Build flexible API request/response models that adapt field optionality based on use case without duplicating model definitions.
- Support partial updates in database operations where only changed fields need to be validated and persisted.
- Generate test fixtures and mock objects where you need to construct models with minimal required data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts pydantic models into partial variants where all or selected fields become optional, enabling flexible validation for PATCH requests and partial response DTOs.
Yes, if you are building APIs with pydantic and FastAPI. The library solves a real gap in pydantic's design for PATCH requests and partial responses. Install friction is negligible, maintenance is active, and the MIT license carries no restrictions. The main caveat is that type checkers will not understand the partial optionality, so use it only for DTO/serialization contexts, not for type-critical business logic.
Install
pydantic-partial on PyPI
pip
pip install pydantic-partialuv
uv add pydantic-partialpoetry
poetry add pydantic-partialInstalling pydantic-partial
Before you install
Low install friction with a single pydantic dependency. Actively maintained with recent releases; last commit 2026-08-08 and latest release 2026-06-26 indicate ongoing support.
License in practice
MIT license permits use in commercial and private projects with minimal restrictions, requiring only license and copyright notice retention.
Quickstart
pip install pydantic-partial
import pydantic
from pydantic_partial import PartialModelMixin
class User(PartialModelMixin, pydantic.BaseModel):
name: str
age: int
UserPartial = User.model_as_partial()
user = UserPartial() # Both fields now optional
Requires Python 3.10 or later and pydantic 2.x; type checkers will not recognize partial field optionality.
Verify before relying
- Whether partial models work correctly with pydantic validators and computed fields beyond the documented examples.
- Performance impact when creating many partial model variants from large model hierarchies.
- Compatibility with pydantic serialization modes (mode='json', mode='python') in partial contexts.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | actively maintained — 49 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 194,591/month — #9,830 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pydantic_partial-0.11.1-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
django-pydantic-fieldProvides type-safe Pydantic model schemas for…
permissive · top 5,000 on PyPI
Flask-PydanticAdds Pydantic model validation to Flask route…
permissive · top 15,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
jsonschema-pydantic-converterConverts JSON Schema definitions to Pydantic v2…
permissive · top 15,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
sparkdanticConverts Pydantic models to PySpark schemas…
unclear · top 5,000 on PyPI
drf-pydanticBridges pydantic models and Django REST…
permissive · top 15,000 on PyPI
pydantic_corepydantic-core provides the high-performance…
permissive · top 100 on PyPI
dydanticDynamically generates Pydantic models from JSON…
permissive · top 5,000 on PyPI
pydantic-numpyIntegrates NumPy arrays into Pydantic models…
permissive · top 15,000 on PyPI