Coverage for docs_src / progressbar / tutorial004_py39.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-02-09 12:36 +0000

1import time 1abcdefgh

2 

3import typer 1abcdefgh

4 

5 

6def iterate_user_ids(): 1abcdefgh

7 # Let's imagine this is a web API, not a range() 

8 for i in range(100): 1abcdefgh

9 yield i 1abcdefgh

10 

11 

12app = typer.Typer() 1abcdefgh

13 

14 

15@app.command() 1abcdefgh

16def main(): 1abcdefgh

17 total = 0 1abcdefgh

18 with typer.progressbar(iterate_user_ids(), length=100) as progress: 1abcdefgh

19 for value in progress: 1abcdefgh

20 # Fake processing time 

21 time.sleep(0.01) 1abcdefgh

22 total += 1 1abcdefgh

23 print(f"Processed {total} user IDs.") 1abcdefgh

24 

25 

26if __name__ == "__main__": 1abcdefgh

27 app() 1abcdefgh