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

9 statements  

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

1import random 1abcdefghij

2from typing import Annotated 1abcdefghij

3 

4import typer 1abcdefghij

5 

6app = typer.Typer() 1abcdefghij

7 

8 

9def get_name(): 1abcdefghij

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

11 

12 

13@app.command() 1abcdefghij

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

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

16 

17 

18if __name__ == "__main__": 1abcdefghij

19 app() 1abcdefghij