Skip to main content

TypeScript-like utilities for Pydantic models: Partial, Pick, Omit, Required

Project description

Pydantic Tooltypes

TypeScript-like utilities for Pydantic models: Partial, Pick, Omit, and Required.

Features

  • Partial: Makes all fields in a Pydantic model optional.
  • Pick: Selects a subset of fields from a model.
  • Omit: Removes a subset of fields from a model.
  • Required: Makes selected fields required, others optional.

All utilities now support class parametrization, similar to generics in TypeScript or Python typing.

Installation

pip install pydantic-tooltypes

Usage

from pydantic import BaseModel
from pydantic_tooltypes import Partial, Pick, Omit, Required

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

# Partial: all fields optional
PartialUser = Partial[User]

# Pick: only selected fields included (and required)
PickUser = Pick[User, ['email']]

# Omit: all except the listed fields (the rest are required)
OmitUser = Omit[User, ['id']]

# Required: make some fields required over a Partial model
RequiredUser = Required[PartialUser, ['email']]

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_tooltypes-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_tooltypes-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_tooltypes-0.2.0.tar.gz.

File metadata

  • Download URL: pydantic_tooltypes-0.2.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-59-generic

File hashes

Hashes for pydantic_tooltypes-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2f719d96aa4e4a9e15855cca047b6f2d689db1d6bd18b8215a16f1286f6efa0e
MD5 0ad2109f32935edae4cad20b2a553dff
BLAKE2b-256 cfbe8ccb0296ed85fb0ca4ae87534af8b10802a08e5e5774a54db18489462d71

See more details on using hashes here.

File details

Details for the file pydantic_tooltypes-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_tooltypes-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-59-generic

File hashes

Hashes for pydantic_tooltypes-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ec68e817bd37a23fc474880c97338c26b9a32d3b941123d3be3e3bb5c55c5d
MD5 19803d77eab88f2fd3e798fd136df54e
BLAKE2b-256 f79b3a8e89fde19046a37d496095a3061e0a05a9911006583335c0176a7fb575

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page