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.13.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.13.0
File Size Uploaded
didactic_pydantic-0.13.0.tar.gz 8.2 kB Details

Built distribution (wheel)

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

Total release size: 18.7 kB

Release files / didactic_pydantic-0.13.0.tar.gz

Download URL didactic_pydantic-0.13.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9db4aa7d8cea58c83469d86b711565d7da7fb7493750cf177a4dd27665b55041
BLAKE2b-256 checksum
How to use checksums
e15b6e14744b58a1064855ce1db808e1a9fcd807d1c9cec676c4712b8d20c507
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 8, 2026.

Transparency log

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

Download URL didactic_pydantic-0.13.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc9eab72fe835a8290ac59c1ac3140c65c8f2f7446d56022d1494769ffe6245c
BLAKE2b-256 checksum
How to use checksums
677a536ff235053464664a03676cb3098cae9035903d7a8dcc1951b72df4bf5a
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 8, 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