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

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.17.4
File Size Uploaded
didactic_pydantic-0.17.4.tar.gz 8.9 kB Details

Built distribution (wheel)

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

Total release size: 19.9 kB

Release files / didactic_pydantic-0.17.4.tar.gz

Download URL didactic_pydantic-0.17.4.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
806dcc4a795ea6804dd19ca2da0f4cb15dfc951cb9114ce0f0a3050ebcbf1afd
BLAKE2b-256 checksum
How to use checksums
83a1de99769206c8ec580098428b0642dcbb61a1c7d7af82e8ae56671c7037e4
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 Oct 9, 2026.

Transparency log

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

Download URL didactic_pydantic-0.17.4-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f87b8ced1054cd07cb830f519921bd91706a20b9f128a106927d9e73a6220c
BLAKE2b-256 checksum
How to use checksums
c197640b4cb2b7915b7371c2a98b380db401813dead8e9a1e64d5bfdce8f5742
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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.18.0

2 release files

0.17.6

2 release files

This release

0.17.4 This release

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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