didactic-pydantic
Bidirectional adapter between pydantic.BaseModel and dx.Model.
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.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| didactic_pydantic-0.15.0.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| didactic_pydantic-0.15.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.8 kB
Release files / didactic_pydantic-0.15.0.tar.gz
| Download URL | didactic_pydantic-0.15.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba064685589365b4570efd219bab6d0039cf46368df7a42d9e23d6cb62e589d2
|
|
BLAKE2b-256 checksum How to use checksums |
eef8e4e30d7edf8509f47c98f2e0f0e5936f6edffd4d84f797390cbb2ae254df
|
| 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 12, 2026.
Transparency logRelease files / didactic_pydantic-0.15.0-py3-none-any.whl
| Download URL | didactic_pydantic-0.15.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7fd5dcb327423d69bced6dd299a6bc3cc489a70a62ca34b970c253b25571be3
|
|
BLAKE2b-256 checksum How to use checksums |
c04faf7ccac88369c4754f27ca09b2f5d3a35d12807bfa5725e429c46ee13629
|
| 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 12, 2026.
Transparency log