Skip to content
Discussion options

You must be logged in to vote

This is because if you have only one command, Typer makes some optimizations and you don't need to specify command to call it. So, it treats async_handle in abcd.py async_handle as an argument, thus it shows that error.

The solution is to add a callback as described here: https://typer.tiangolo.com/tutorial/commands/one-or-multiple/#one-command-and-one-callback

from asyncio import run as aiorun
import typer

app = typer.Typer()

async def async_process():
    print("hello I am async")


@app.command()
def async_handle():
    aiorun(async_process())

@app.callback()
def callback():
    pass

if __name__ == "__main__":
    app()

And, your command name will actually be async-handle (with das…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants