Coverage for docs_src/options/callback/tutorial001_an.py: 100%
9 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1from typing import Optional 1abcdefgh
3import typer 1abcdefgh
4from typing_extensions import Annotated 1abcdefgh
7def name_callback(value: str): 1abcdefgh
8 if value != "Camila": 1abcdefgh
9 raise typer.BadParameter("Only Camila is allowed") 1abcdefgh
10 return value 1abcdefgh
13def main(name: Annotated[Optional[str], typer.Option(callback=name_callback)] = None): 1abcdefgh
14 print(f"Hello {name}") 1abcdefgh
17if __name__ == "__main__": 1abcdefgh
18 typer.run(main) 1abcdefgh