Skip to main content

didactic-pydantic

PyPI Python License CI Docs

didactic-pydantic converts models between pydantic.BaseModel and didactic.api.Model. It adds the didactic.pydantic module and supports applications that need both model systems during a migration.

Install

pip install didactic-pydantic

The distribution depends on didactic and pydantic>=2.10.

Convert a Pydantic model

from_pydantic creates a Didactic model class:

from pydantic import BaseModel, Field

from didactic.pydantic import from_pydantic


class PydanticUser(BaseModel):
    id: str
    email: str = Field(description="Primary contact")


User = from_pydantic(PydanticUser)
user = User(id="u1", email="alice@example.com")

The conversion preserves annotations, defaults, factories, aliases, descriptions, examples, deprecation flags, and Annotated constraint metadata. Constraints from annotated-types, such as Ge and Le, become Didactic axioms.

Convert a Didactic model

to_pydantic creates a Pydantic model class:

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


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


PydanticUser = to_pydantic(User)
user = PydanticUser(id="u1", email="alice@example.com")

The adapter caches generated classes. Repeated calls with the same input class return the same output class.

Translation boundary

Pydantic field validators, model validators, computed fields, and discriminated unions require corresponding Didactic definitions after conversion. They are not copied by from_pydantic.

Didactic models with dx.indexed_by fields retain their cross-field checks in the generated Pydantic class. Their JSON Schema also retains the conditional cases associated with known indices.

Documentation

See the Pydantic interop guide for the conversion matrix and round-trip behavior.

License

Released under the MIT License.

Metadata

Release files for didactic-pydantic 0.18.3

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.18.3
File Size Uploaded Provenance Actions
didactic_pydantic-0.18.3.tar.gz 8.9 kB With provenance Details for didactic_pydantic-0.18.3.tar.gz

Built distribution (wheel)

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

Total release size: 20.0 kB

Release files / didactic_pydantic-0.18.3.tar.gz

Download URL didactic_pydantic-0.18.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4070cdcfea2ec4397eeb2625ccbe5afee8c18badf8e6baa82d1a67bc4d011315
BLAKE2b-256 checksum
How to use checksums
3c9edfddcb003f535dc08fa90bbde81b63ee72f51be9ec45f01b839a66e3b195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 25, 2026.

Transparency log

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

Download URL didactic_pydantic-0.18.3-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b43c7bd694945df2e45970143628c3d613a76cdbe0c5aafd5aa446786ac77387
BLAKE2b-256 checksum
How to use checksums
e485a771b2d5ca8ebfefa5c9481d748515ebcb5139d982cb1ae4e61ea1695c2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 25, 2026.

Transparency log

Security for didactic-pydantic 0.18.3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for didactic_pydantic-0.18.3.tar.gz

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 Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.18.3 This release

2 release files Full provenance

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