Pydantic interop for didactic — adapters for incremental migration.
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file didactic_pydantic-0.2.0.tar.gz.
File metadata
- Download URL: didactic_pydantic-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90f9f64348fe15e922946c5c6133b8d4b7f0d6f1560e3abd571898b6cef82393
|
|
| MD5 |
220fb8e29c9f4ca0d86b929ee2c73385
|
|
| BLAKE2b-256 |
b74487243c03f7400a52b0689850eeceea2414e8fefdf6fbdbafa552ec9d092b
|
Provenance
The following attestation bundles were made for didactic_pydantic-0.2.0.tar.gz:
Publisher:
release.yml on panproto/didactic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
didactic_pydantic-0.2.0.tar.gz -
Subject digest:
90f9f64348fe15e922946c5c6133b8d4b7f0d6f1560e3abd571898b6cef82393 - Sigstore transparency entry: 1421374538
- Sigstore integration time:
-
Permalink:
panproto/didactic@ff06b14671217c1052b7683634ff32f267c19855 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/panproto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff06b14671217c1052b7683634ff32f267c19855 -
Trigger Event:
push
-
Statement type:
File details
Details for the file didactic_pydantic-0.2.0-py3-none-any.whl.
File metadata
- Download URL: didactic_pydantic-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b66aa028c7191d8d8a3965de4eb0405d9fb3fd14ffe14e3545761f2efcafec3
|
|
| MD5 |
014f8b3f26557081f7873030a644fb0c
|
|
| BLAKE2b-256 |
9abe892a1d17768d90104e94d9f2e385b6fe8a595d62896f2346407de0ae2814
|
Provenance
The following attestation bundles were made for didactic_pydantic-0.2.0-py3-none-any.whl:
Publisher:
release.yml on panproto/didactic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
didactic_pydantic-0.2.0-py3-none-any.whl -
Subject digest:
8b66aa028c7191d8d8a3965de4eb0405d9fb3fd14ffe14e3545761f2efcafec3 - Sigstore transparency entry: 1421374637
- Sigstore integration time:
-
Permalink:
panproto/didactic@ff06b14671217c1052b7683634ff32f267c19855 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/panproto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff06b14671217c1052b7683634ff32f267c19855 -
Trigger Event:
push
-
Statement type: