Coverage for docs_src / options_autocompletion / tutorial003_non_an.py: 100%
12 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
3valid_names = ["Camila", "Carlos", "Sebastian"] 1abcdefghij
6def complete_name(incomplete: str): 1abcdefghij
7 completion = [] 1abcdefghij
8 for name in valid_names: 1abcdefghij
9 if name.startswith(incomplete): 1abcdefghij
10 completion.append(name) 1abcdefghij
11 return completion 1abcdefghij
14app = typer.Typer() 1abcdefghij
17@app.command() 1abcdefghij
18def main( 1abcdefghij
19 name: str = typer.Option(
20 "World", help="The name to say hi to.", autocompletion=complete_name
21 ),
22):
23 print(f"Hello {name}") 1abcdefghij
26if __name__ == "__main__": 1abcdefghij
27 app() 1abcdefghij