pypi async-typer 0.2.0

latest release: 0.2.1
4 hours ago

Highlights

Unified sync/async API. @app.command() and @app.callback() now accept both regular and async def functions via the same decorator — no separate API to remember. Typer's --help, option parsing, and type conversion all work transparently.

Lifecycle event handlers. Register startup/shutdown hooks (sync or async) with app.add_event_handler(...). They run on the same asyncio.Runner as the command body, so async resources created on startup (pools, HTTP sessions) stay usable through the command and shutdown. Shutdown runs even if the command raises, and never masks the primary exception.

Drop-in replacement. Re-exports Typer's public API (Option, Argument, echo, …) so a single from async_typer import ... works.

Fully typed. Ships py.typed with strict hints.

Python 3.14 support added; tested across 3.11–3.14.

Deprecations

async_command / async_callback still work but now emit DeprecationWarning. Use the unified command / callback, which auto-detect async def.

# before
@app.async_command()
async def foo(): ...

# after
@app.command()
async def foo(): ...

Known limitations

When both an async callback and an async command are present, lifecycle handlers currently fire once around the callback and once around the command (on separate event loops). If you rely on a shared async resource across the whole invocation, avoid pairing an async callback with lifecycle handlers for now. A fix is planned for a follow-up release.

Full changelog: 0.1.10...0.2.0

Don't miss a new async-typer release

NewReleases is sending notifications on new releases.