--- id: pydantic-partial version: "0.11.1" license: MIT license_treatment: permissive maintenance: active --- # pydantic-partial — Create partial models from your pydantic models. Partial models may allow None for certain or all fields. License: permissive · Maintenance: active · Downloads: 194.6K/mo ## 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 above — 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 pip install pydantic-partial uv add pydantic-partial poetry add pydantic-partial ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 194.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pydantic optional fields, partial models pydantic, patch request validation, optional pydantic fields, pydantic dto partial, flexible field validation, pydantic model variants, pydantic-extension, api-dto, patch-requests [View on SkillFed](https://skillfed.io/packages/pydantic-partial) · [View on PyPI](https://pypi.org/project/pydantic-partial/)