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.10+

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.10+.

$ 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:

$ uv add 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)

The built-in anyquart run command is only available on anyquart <= 0.2.1 — from 0.3.0 onward, run the ASGI server directly as shown 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

Release files for anyquart 0.3.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 0.3.0
File Size Uploaded
anyquart-0.3.0.tar.gz 69.3 kB Details

Built distribution (wheel)

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

Total release size: 152.0 kB

Release files / anyquart-0.3.0.tar.gz

Download URL anyquart-0.3.0.tar.gz
Size 69.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4976e9794548b36c67e1d06da141e2e0c21f46bd68e41cf63570cba3fd034d27
BLAKE2b-256 checksum
How to use checksums
d531f4f9d7331201139f8b0fd5eaa65c7cd8fb7a8e78af28829615fc8bbab362
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 7, 2026.

Transparency log

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

Download URL anyquart-0.3.0-py3-none-any.whl
Size 82.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fbc6ba521fe852c52ffc8ce0765e261c274bb04389294c98ec5ec59fe9d1209
BLAKE2b-256 checksum
How to use checksums
600e998309ed049323b87fa4aadbf3ff0c2f11efce31f31493ea12376a735b59
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 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

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