typer
typer copied to clipboard
Support parameter type typing.Dict[str, typing.Any]
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.
The workaround, for now, is to remove the type hint from the config param (which also disables type checking).