typer icon indicating copy to clipboard operation
typer copied to clipboard

Support parameter type typing.Dict[str, typing.Any]

Open tekumara opened this issue 5 years ago • 3 comments

My CLI app can use a profile key, which is used to load the appropriate config:

def load_profile(profile: str) -> Dict[str, Any]:
    ...

@app.command()
def describe(
    config: Dict[str, Any] = typer.Option(None, "--profile", help="Profile in the config file to use", callback=load_profile),
) -> List[Dict[str, Any]]:

However, this errors with:

RuntimeError: Type not yet supported: typing.Dict[str, typing.Any]

The solution you would like

The ability to support Dict as a type, when returned from a callback function.

tekumara avatar Jun 28 '20 12:06 tekumara

The workaround, for now, is to remove the type hint from the config param (which also disables type checking).

tekumara avatar Jun 28 '20 12:06 tekumara