{"library":"pydantic-partial","title":"Pydantic Partial Models","description":"pydantic-partial is a Python library that allows you to create 'partial' Pydantic models. These partial models can have some or all of their fields marked as optional (allowing `None` values) or removed from being required, making them suitable for PATCH requests or incremental updates where not all data is available. The current version is 0.10.2, and it maintains an active release cadence with minor updates and dependency bumps every few weeks or months.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pydantic-partial"],"cli":null},"imports":["from pydantic_partial import create_partial_model","from pydantic_partial import Partial"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from pydantic import BaseModel\nfrom pydantic_partial import create_partial_model\n\nclass User(BaseModel):\n    name: str\n    email: str\n    age: int = 18\n    is_active: bool = True\n\n# Create a partial model where all fields are optional\nPartialUser = create_partial_model(User)\n\n# Instantiate the partial model with only some fields\npartial_user_data = {\n    \"name\": \"Alice\",\n    \"age\": None # age is optional now\n}\nuser_update = PartialUser(**partial_user_data)\n\nprint(user_update.model_dump())\n\n# Create a partial model excluding required fields, making them Optional\n# and allowing fields to be completely omitted from input\nPartialUserPatch = create_partial_model(User, exclude_required_fields=True)\n\npatch_data = {\n    \"email\": \"alice@example.com\"\n} # name is not required now\npatch_user = PartialUserPatch(**patch_data)\n\nprint(patch_user.model_dump())","lang":"python","description":"This quickstart demonstrates how to create a basic Pydantic model and then use `create_partial_model` to generate a new model where all original fields become optional. It also shows how to use `exclude_required_fields=True` to make fields not just optional (allowing `None`) but also completely omittable from input, ideal for PATCH operations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}