Coverage for docs_src / options / callback / tutorial001_non_an.py: 100%
9 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 if value != "Camila": 1abcdefghij
8 raise typer.BadParameter("Only Camila is allowed") 1abcdefghij
9 return value 1abcdefghij
12@app.command() 1abcdefghij
13def main(name: str | None = typer.Option(default=None, callback=name_callback)): 1abcdefghij
14 print(f"Hello {name}") 1abcdefghij
17if __name__ == "__main__": 1abcdefghij
18 app() 1abcdefghij