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.
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.
- Works with both asyncio and Trio code via AnyIO, giving you structured concurrency out of the box.
- aiofiles dropped, AnyIO's file I/O is used instead.
- pytest-asyncio replaced by AnyIO pytest plugin.
- 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.
- As of 0.3.0, AnyQuart provides a Request-scoped dependency injection for route handlers.
Request handlers may mark parameters with :class:
Needsto 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
- 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 ✨
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4976e9794548b36c67e1d06da141e2e0c21f46bd68e41cf63570cba3fd034d27
|
|
| MD5 |
e7b07e16ee020d9d503b4ba5ad0659fb
|
|
| BLAKE2b-256 |
d531f4f9d7331201139f8b0fd5eaa65c7cd8fb7a8e78af28829615fc8bbab362
|
Provenance
The following attestation bundles were made for anyquart-0.3.0.tar.gz:
Publisher:
publish.yaml on EmmanuelNiyonshuti/anyquart
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyquart-0.3.0.tar.gz -
Subject digest:
4976e9794548b36c67e1d06da141e2e0c21f46bd68e41cf63570cba3fd034d27 - Sigstore transparency entry: 2367743624
- Sigstore integration time:
-
Permalink:
EmmanuelNiyonshuti/anyquart@f3f8398306a2747f57daf0d54b1c7ea59fa80be9 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/EmmanuelNiyonshuti
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f3f8398306a2747f57daf0d54b1c7ea59fa80be9 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fbc6ba521fe852c52ffc8ce0765e261c274bb04389294c98ec5ec59fe9d1209
|
|
| MD5 |
cb8f2b3bc5ad6da93bb8acd8f6f6a105
|
|
| BLAKE2b-256 |
600e998309ed049323b87fa4aadbf3ff0c2f11efce31f31493ea12376a735b59
|
Provenance
The following attestation bundles were made for anyquart-0.3.0-py3-none-any.whl:
Publisher:
publish.yaml on EmmanuelNiyonshuti/anyquart
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyquart-0.3.0-py3-none-any.whl -
Subject digest:
2fbc6ba521fe852c52ffc8ce0765e261c274bb04389294c98ec5ec59fe9d1209 - Sigstore transparency entry: 2367743694
- Sigstore integration time:
-
Permalink:
EmmanuelNiyonshuti/anyquart@f3f8398306a2747f57daf0d54b1c7ea59fa80be9 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/EmmanuelNiyonshuti
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f3f8398306a2747f57daf0d54b1c7ea59fa80be9 -
Trigger Event:
push
-
Statement type: