Coverage for tests/test_completion/colon_example.py: 100%

10 statements  

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

1import typer 1iabcdefgh

2 

3image_desc = [ 1abcdefgh

4 ("alpine:latest", "latest alpine image"), 

5 ("alpine:hello", "fake image: for testing"), 

6 ("nvidia/cuda:10.0-devel-ubuntu18.04", ""), 

7] 

8 

9 

10def _complete(incomplete: str) -> str: 1iabcdefgh

11 for image, desc in image_desc: 1iabcdefgh

12 if image.startswith(incomplete): 1iabcdefgh

13 yield image, desc 1iabcdefgh

14 

15 

16app = typer.Typer() 1iabcdefgh

17 

18 

19@app.command() 1iabcdefgh

20def image(name: str = typer.Option(autocompletion=_complete)): 1iabcdefgh

21 typer.echo(name) 1iabcdefgh

22 

23 

24if __name__ == "__main__": 1iabcdefgh

25 app() 1iabcdefgh