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

1import typer 1abcdefghij

2 

3app = typer.Typer() 1abcdefghij

4 

5 

6def name_callback(value: str): 1abcdefghij

7 if value != "Camila": 1abcdefghij

8 raise typer.BadParameter("Only Camila is allowed") 1abcdefghij

9 return value 1abcdefghij

10 

11 

12@app.command() 1abcdefghij

13def main(name: str | None = typer.Option(default=None, callback=name_callback)): 1abcdefghij

14 print(f"Hello {name}") 1abcdefghij

15 

16 

17if __name__ == "__main__": 1abcdefghij

18 app() 1abcdefghij