async-typer

raw JSON →
0.1.10 verified Fri May 01 auth: no python

A lightweight async wrapper around Typer that allows defining Typer commands using async functions. Version 0.1.10 requires Python >=3.10 and <4.0. Released as needed.

pip install async-typer
error ModuleNotFoundError: No module named 'async_typer'
cause async-typer not installed.
fix
Run 'pip install async-typer'
error TypeError: Command function is not async
cause Defined a sync function instead of async with @app.command().
fix
Add 'async' to the function definition.
error async-typer expects async functions for commands, but typer's callback is sync
cause Using @app.callback() which isn't supported for async functions.
fix
Use regular Typer for callbacks or implement a sync wrapper.
gotcha AsyncTyper does not support all Typer features like callback or dependency injection. Use only async commands with simple parameters.
fix If you need advanced Typer features, stick to synchronous Typer or wrap async calls manually.
deprecated The library is in early development. The API may change without notice.
fix Pin the version and test after upgrades.

Basic async command using AsyncTyper.

import asyncio
from async_typer import AsyncTyper

app = AsyncTyper()

@app.command()
async def greet(name: str):
    """Greet someone."""
    await asyncio.sleep(1)
    print(f"Hello, {name}!")

if __name__ == "__main__":
    app()