Skip to main content

anyquart_pydantic

anyquart extension for request and response validation with pydantic.

Annotate your route handlers with pydantic models and the body and response are validated automatically.

Tests PyPI Python License t

Install

pip install anyquart_pydantic

Usage

Here is a simple example:

# app.py
from pydantic import BaseModel

from anyquart import AnyQuart
from anyquart import jsonify

from anyquart_pydantic import AnyQuartPydantic

app = AnyQuart(__name__)
AnyQuartPydantic(app)


class User(BaseModel):
    email: str

class UserIn(User):
    password: str
    username: str | None = None

class UserOut(User):
    uid: str
    username: str

@app.route("/users", methods=["POST"])
async def create_user(user: UserIn) -> UserOut:
    if user.username is None:
        user.username = user.email.split("@")[0]
    # do other stuffs(e.g: save to the database)
    #
    # and return a new registered user with a generated uuid primary key from the database
    new_user = UserOut(
        uid="66b652e0-f114-46d7-b426-e0601233bab2",
        username=user.username
    )
    return new_user, 201

Run the application:

$ anyquart --app app:app run

send a request:

$ curl -X POST http://localhost:5000/users \
    -H "Content-Type: application/json" \
    -d '{"email": "foo@bar.com", "password": "super_secret!"}'

#response:
{
    "uid": "66b652e0-f114-46d7-b426-e0601233bab2",
    "username": "foo"
}

Contributing

Contributions are very welcome. Tests can be run with tox. To run tests on all environments in parallel tox -p, run test on specific environment tox -e py315 -- tests. You can also use uv uv sync.

License

MIT

Release files for anyquart-pydantic 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyquart-pydantic 0.2.0
File Size Uploaded
anyquart_pydantic-0.2.0.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyquart-pydantic 0.2.0
File Interpreter ABI Platform
anyquart_pydantic-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / anyquart_pydantic-0.2.0.tar.gz

Download URL anyquart_pydantic-0.2.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c776dff8b16fc35c1ddf41c68b005b42d23c8edb2d98e71b7f8c2599e75eae30
BLAKE2b-256 checksum
How to use checksums
fccc1f162446bc88ecb5c6c0ae4d99e822d9aaa63e9329061143f6489b928369
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 Aug 22, 2026.

Transparency log

Release files / anyquart_pydantic-0.2.0-py3-none-any.whl

Download URL anyquart_pydantic-0.2.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d101c16cf55dca41908e4978a7e796034b16012574fdad6d48878e049f566df0
BLAKE2b-256 checksum
How to use checksums
5275139f9ad0188a737887b6578645bca532a10c21525ec271ec2781600f2f40
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 Aug 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

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