Coverage for docs_src / arguments / default / tutorial002_an_py39.py: 100%

9 statements  

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

1import random 1abcdefgh

2from typing import Annotated 1abcdefgh

3 

4import typer 1abcdefgh

5 

6app = typer.Typer() 1abcdefgh

7 

8 

9def get_name(): 1abcdefgh

10 return random.choice(["Deadpool", "Rick", "Morty", "Hiro"]) 1abcdefgh

11 

12 

13@app.command() 1abcdefgh

14def main(name: Annotated[str, typer.Argument(default_factory=get_name)]): 1abcdefgh

15 print(f"Hello {name}") 1abcdefgh

16 

17 

18if __name__ == "__main__": 1abcdefgh

19 app() 1abcdefgh