How to use the typer.BadParameter function in typer

To help you get started, weโ€™ve selected a few typer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tiangolo / typer / docs_src / options / version / tutorial002.py View on Github external
def name_callback(name: str):
    if name != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
github tiangolo / typer / docs_src / options / callback / tutorial003.py View on Github external
def name_callback(ctx: typer.Context, value: str):
    if ctx.resilient_parsing:
        return
    typer.echo("Validating name")
    if value != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
    return value
github tiangolo / typer / docs_src / options / callback / tutorial001.py View on Github external
def name_callback(value: str):
    if value != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
    return value
github tiangolo / typer / docs_src / options / callback / tutorial002.py View on Github external
def name_callback(value: str):
    typer.echo("Validating name")
    if value != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
    return value
github tiangolo / typer / docs_src / options / version / tutorial003.py View on Github external
def name_callback(name: str):
    if name != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
    return name
github tiangolo / typer / docs_src / options / callback / tutorial004.py View on Github external
def name_callback(ctx: typer.Context, param: typer.CallbackParam, value: str):
    if ctx.resilient_parsing:
        return
    typer.echo(f"Validating param: {param.name}")
    if value != "Camila":
        raise typer.BadParameter("Only Camila is allowed")
    return value