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

8 statements  

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

1import random 1abcdefghij

2 

3import typer 1abcdefghij

4 

5app = typer.Typer() 1abcdefghij

6 

7 

8def get_name(): 1abcdefghij

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

10 

11 

12@app.command() 1abcdefghij

13def main(name: str = typer.Argument(default_factory=get_name)): 1abcdefghij

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

15 

16 

17if __name__ == "__main__": 1abcdefghij

18 app() 1abcdefghij