This release is a pre-release and may not be stable for production use.
benzene-pydantic
Validate a Benzene handler's request with a pydantic model — the Python ecosystem's standard for parsing and validating request data — for the Benzene Python port.
Depends on benzene-core and pydantic. The core stays
pydantic-free; this optional adapter is the one place the dependency lives.
pip install benzene-pydantic
from benzene.core import message
from benzene.pydantic import validated
from benzene.results import Result
from pydantic import BaseModel
class PlaceOrder(BaseModel):
sku: str
quantity: int = 1
@message("orders:place") # no request_type — the raw body flows in and @validated checks it
@validated(PlaceOrder)
async def place(order: PlaceOrder) -> Result:
return Result.created(order) # a pydantic model returned as payload serializes on the wire
@validated(Model) validates the decoded body into Model before your handler runs. A
pydantic.ValidationError becomes a validation-error Result that names each bad field, so a
malformed request never reaches your handler and never crashes the pipeline:
# POST {"quantity": "not-an-int"} -> status "validation-error"
# detail: "sku: Field required, quantity: Input should be a valid integer, ..."
A pydantic model returned as a success payload is serialized by benzene.core's wire mapper
(model_dump(by_alias=True)). Unlike a dataclass — whose fields the mapper auto-camelCases — a
pydantic model is dumped under its own field names, so give the model a camelCase alias_generator
to cross the wire in the Benzene naming policy (then it matches a dataclass response).
Contributes the benzene.pydantic subpackage to the shared benzene namespace.
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 benzene_pydantic-0.1.0b1.tar.gz.
File metadata
- Download URL: benzene_pydantic-0.1.0b1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4b70637323732648c230f5985642edab980b3bab93a0c37b0406c4331460000
|
|
| MD5 |
cc087f79f6b4e42a3f2afd010a2527fe
|
|
| BLAKE2b-256 |
b720d67f1568571e468cb0cb70286759de1fa02d27c85bbb886530e90eed2898
|
Provenance
The following attestation bundles were made for benzene_pydantic-0.1.0b1.tar.gz:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_pydantic-0.1.0b1.tar.gz -
Subject digest:
d4b70637323732648c230f5985642edab980b3bab93a0c37b0406c4331460000 - Sigstore transparency entry: 2467247399
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file benzene_pydantic-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: benzene_pydantic-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05a73a9787b4bd0c24538baac728db66b7ba9eebc798b9ab30423984e3267b60
|
|
| MD5 |
abcfa96ad2be00c6d271fc063a5f6373
|
|
| BLAKE2b-256 |
3ae66f086b408545d6fd5c4740b66759acb7061dd60e9d9212e8b7aefd04c90f
|
Provenance
The following attestation bundles were made for benzene_pydantic-0.1.0b1-py3-none-any.whl:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_pydantic-0.1.0b1-py3-none-any.whl -
Subject digest:
05a73a9787b4bd0c24538baac728db66b7ba9eebc798b9ab30423984e3267b60 - Sigstore transparency entry: 2467231338
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type: