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.10.1

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.10.1
File Size Uploaded
didactic_pydantic-0.10.1.tar.gz 8.2 kB Details

Built distribution (wheel)

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

Total release size: 18.7 kB

Release files / didactic_pydantic-0.10.1.tar.gz

Download URL didactic_pydantic-0.10.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fdebcc6b5764ebe87fe509790aa332511c0b67e1877e1c4e647cb2a168d7b6e1
BLAKE2b-256 checksum
How to use checksums
028e8cce1a11a88272123208203f4e9cb1275d5a35b06f0f4a25217727674bf0
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 Aug 26, 2026.

Transparency log

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

Download URL didactic_pydantic-0.10.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44e6ae92a488a1bc33d303a6d6cd648bd14b1f9c6710bcd7681b6e8b2e00bede
BLAKE2b-256 checksum
How to use checksums
346821cc9bd61cf59ccd00c757152594fdd7dc14c6713ee9e5134a136ea91dc3
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 Aug 26, 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