Coverage for docs_src / options / callback / tutorial002_non_an.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
1import typer 1abcdefghij
3app = typer.Typer() 1abcdefghij
6def name_callback(value: str): 1abcdefghij
7 print("Validating name") 1abcdefghij
8 if value != "Camila": 1abcdefghij
9 raise typer.BadParameter("Only Camila is allowed") 1abcdefghij
10 return value 1abcdefghij
13@app.command() 1abcdefghij
14def main(name: str | None = typer.Option(default=None, callback=name_callback)): 1abcdefghij
15 print(f"Hello {name}") 1abcdefghij
18if __name__ == "__main__": 1abcdefghij
19 app() 1abcdefghij