Coverage for docs_src/options_autocompletion/tutorial002_an.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-04-14 00:18 +0000

1import typer 1iabcdefgh

2from typing_extensions import Annotated 1iabcdefgh

3 

4 

5def complete_name(): 1iabcdefgh

6 return ["Camila", "Carlos", "Sebastian"] 1iabcdefgh

7 

8 

9app = typer.Typer() 1iabcdefgh

10 

11 

12@app.command() 1iabcdefgh

13def main( 1abcdefgh

14 name: Annotated[ 

15 str, typer.Option(help="The name to say hi to.", autocompletion=complete_name) 

16 ] = "World", 

17): 

18 print(f"Hello {name}") 1iabcdefgh

19 

20 

21if __name__ == "__main__": 1iabcdefgh

22 app() 1iabcdefgh