Skip to main content

didactic-pydantic

Bidirectional adapter between pydantic.BaseModel and dx.Model.

PyPI Python License CI Docs

Contributes didactic.pydantic to the namespace package.

Install

pip install didactic-pydantic

The package depends on didactic and pydantic>=2.10.

Quickstart

from_pydantic converts a pydantic.BaseModel subclass into a dx.Model subclass:

from pydantic import BaseModel, Field
from didactic.pydantic import from_pydantic


class PydUser(BaseModel):
    id: str
    email: str = Field(description="primary contact")


User = from_pydantic(PydUser)

Field annotations, defaults, factories, aliases, descriptions, examples, and the deprecated flag carry across. Annotated[T, ...] constraint metadata flows through unchanged, so annotated-types primitives (Ge, Le, ...) continue to produce axioms on the didactic side.

Custom Pydantic validators (@field_validator, @model_validator), @computed_field, and discriminated unions are not translated; the Pydantic interop guide lists the didactic-side replacements.

to_pydantic is the inverse direction:

import didactic.api as dx
from didactic.pydantic import to_pydantic


class User(dx.Model):
    id: str
    email: str = dx.field(description="primary contact")


PydUser = to_pydantic(User)

Use to_pydantic to expose a dx.Model to FastAPI, OpenAPI generators, or any other Pydantic-shaped tool. The conversion is cached, so repeated calls with the same input return the same Pydantic class.

Documentation

See Guides > Pydantic interop for the full feature matrix and round-trip behaviour.

License

Released under the MIT License.

Metadata

Release files for didactic-pydantic 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for didactic-pydantic 0.14.0
File Size Uploaded
didactic_pydantic-0.14.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for didactic-pydantic 0.14.0
File Interpreter ABI Platform
didactic_pydantic-0.14.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / didactic_pydantic-0.14.0.tar.gz

Download URL didactic_pydantic-0.14.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f08b4bee310385dac3ef3fee3fe2edda590a723f9fde7a0a5862b99f2eac55eb
BLAKE2b-256 checksum
How to use checksums
5446934c303853e67af99014251503529b29c72e908d14a80ac0fb7359376b3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / didactic_pydantic-0.14.0-py3-none-any.whl

Download URL didactic_pydantic-0.14.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84d84dcdf704422baeec7cd897a7ce328940a590c59e2ba1bae064525b4a44f3
BLAKE2b-256 checksum
How to use checksums
6f838cfb515e422f0a6ca72b9511c3f64417dcb0438f4bcf43e5c3e1e0d60dbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page