Skip to main content

AnyQuart

Quart runs on Asyncio and when you want to run it on Trio event loop you use quart-trio extension.

AnyQuart is Quart running on AnyIO. It is a fork of Quart 0.20.1.

Tests PyPI Python License t

Differences from Quart

AnyQuart and Quart are essentially the same thing. The only difference is the name and the internals(Asyncio replaced with AnyIO). This also means the testing setup changes, which is explained in the Testing section below.

  1. Works with both asyncio and Trio code via AnyIO, giving you structured concurrency out of the box.
  2. aiofiles dropped, AnyIO's file I/O is used instead.
  3. pytest-asyncio replaced by AnyIO pytest plugin.
  4. As of 0.3.0, Anycorn is an optional dependency for the development server, while Quart installs Hypercorn as a required dependency for the same purpose.
  5. As of 0.3.0, AnyQuart provides a Request-scoped dependency injection for route handlers. Request handlers may mark parameters with :class:Needs to resolve a request-scoped value. e.g:
    from anyquart import Needs
    
    
    async def get_db() -> AsyncGenerator[AsyncSession, None]:
        async with async_session() as session:
            yield session
    
    
    @app.route("/users")
    async def get_users(db: AsyncSession = Needs(get_db)) -> None: ...
    
    
    # Or:
    DBSession = Annotated[AsyncSession, Needs(get_db)]
    
    
    @app.route("/users")
    async def get_users(db: DBSession) -> None: ...
    
    
    # Tests can use `app.dependency_overrides` dictionary to replace route handler's
    # dependency with test dependency
    
  6. Runs on Python 3.11+

Usage

You will have to replace quart with anyquart and Quart with AnyQuart.

Install from PyPI using an installer such as pip. Requires Python 3.11+.

$ pip install anyquart

Save the following as app.py.

from anyquart import AnyQuart, websocket, render_template

app = AnyQuart(__name__)


@app.route("/")
async def hello():
    return await render_template("index.html")


@app.route("/api")
async def json():
    return {"hello": "world"}


@app.websocket("/ws")
async def ws():
    while True:
        await websocket.send("hello")
        await websocket.send_json({"hello": "world"})

Install an ASGI web server, pick one from this list, or install anyquart with Anycorn directly:

$ pip install anyquart[anycorn]

run the application:

$ anycorn app:app
 * [2026-08-01 11:49:46 +0200] [30809] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)

Note: As of 0.3.0, anyquart run requires an ASGI web server to be installed. If no ASGI web server is available, running the application in development mode will raise a RuntimeError. Install AnyQuart with Anycorn using the command above, or install another ASGI web server from the list above.

Testing

Pytest requires a plugin to run asynchronous test functions and fixtures. Quart uses pytest-asyncio, while AnyQuart uses AnyIO's pytest plugin. You will need to specify which backend your tests run on via the anyio_backend fixture and decorate your asynchronous tests with @pytest.mark.anyio.

import pytest

from app import app


@pytest.fixture()
def anyio_backend():
    return "trio"  # you can replace with "asyncio"


@pytest.fixture()
def test_client():
    return app.test_client()


@pytest.mark.anyio
async def test_do_something(test_client) -> None:
    response = await test_client.get("/")
    assert response.status_code == 200
    assert await response.json == {"hello": "world"}

Refer to the Quart documentation for more details.

Contributing

Issues and Pull Requests are welcome.

Contributors ✨

See All Contributors

Metadata

Release files for anyquart 0.3.1

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 0.3.1
File Size Uploaded Provenance Actions
anyquart-0.3.1.tar.gz 70.4 kB With provenance Details for anyquart-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 153.3 kB

Release files / anyquart-0.3.1.tar.gz

Download URL anyquart-0.3.1.tar.gz
Size 70.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7affceb0d298e8a12623c5acf4e056023e761ea5bae7fefdbef5dcff203d46e0
BLAKE2b-256 checksum
How to use checksums
a2a998596f60e5186859c33b0adaa9f8951e6cc6f6225334355254d73d189e8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Release files / anyquart-0.3.1-py3-none-any.whl

Download URL anyquart-0.3.1-py3-none-any.whl
Size 82.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f60ab8fa0a7872b4055d45e123a61fe4ee21d5770c370e6b674c82d10cb8a3e
BLAKE2b-256 checksum
How to use checksums
cd31890ab488dd20dd6075c4e16d3f538ddca6e92e702631ad2112eb797cfb16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Security for anyquart 0.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anyquart-0.3.1.tar.gz

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 Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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