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

14 statements  

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

1import time 1abcdefghij

2 

3import typer 1abcdefghij

4 

5 

6def iterate_user_ids(): 1abcdefghij

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

8 for i in range(100): 1abcdefghij

9 yield i 1abcdefghij

10 

11 

12app = typer.Typer() 1abcdefghij

13 

14 

15@app.command() 1abcdefghij

16def main(): 1abcdefghij

17 total = 0 1abcdefghij

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

19 for value in progress: 1abcdefghij

20 # Fake processing time 

21 time.sleep(0.01) 1abcdefghij

22 total += 1 1abcdefghij

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

24 

25 

26if __name__ == "__main__": 1abcdefghij

27 app() 1abcdefghij