Coverage for docs_src / options_autocompletion / tutorial005_non_an.py: 100%
10 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_completion_items = [ 1abcdefghij
4 ("Camila", "The reader of books."),
5 ("Carlos", "The writer of scripts."),
6 ("Sebastian", "The type hints guy."),
7]
10def complete_name(incomplete: str): 1abcdefghij
11 for name, help_text in valid_completion_items: 1abcdefghij
12 if name.startswith(incomplete): 1abcdefghij
13 yield (name, help_text) 1abcdefghij
16app = typer.Typer() 1abcdefghij
19@app.command() 1abcdefghij
20def main( 1abcdefghij
21 name: str = typer.Option(
22 "World", help="The name to say hi to.", autocompletion=complete_name
23 ),
24):
25 print(f"Hello {name}") 1abcdefghij
28if __name__ == "__main__": 1abcdefghij
29 app() 1abcdefghij