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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyquart-0.3.0.tar.gz (69.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyquart-0.3.0-py3-none-any.whl (82.7 kB view details)

Uploaded Python 3

File details

Details for the file anyquart-0.3.0.tar.gz.

File metadata

  • Download URL: anyquart-0.3.0.tar.gz
  • Upload date:
  • Size: 69.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyquart-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4976e9794548b36c67e1d06da141e2e0c21f46bd68e41cf63570cba3fd034d27
MD5 e7b07e16ee020d9d503b4ba5ad0659fb
BLAKE2b-256 d531f4f9d7331201139f8b0fd5eaa65c7cd8fb7a8e78af28829615fc8bbab362

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.3.0.tar.gz:

Publisher: publish.yaml on EmmanuelNiyonshuti/anyquart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyquart-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: anyquart-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 82.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyquart-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fbc6ba521fe852c52ffc8ce0765e261c274bb04389294c98ec5ec59fe9d1209
MD5 cb8f2b3bc5ad6da93bb8acd8f6f6a105
BLAKE2b-256 600e998309ed049323b87fa4aadbf3ff0c2f11efce31f31493ea12376a735b59

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.3.0-py3-none-any.whl:

Publisher: publish.yaml on EmmanuelNiyonshuti/anyquart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page