Coverage for docs_src / subcommands / name_help / tutorial007_py39.py: 100%

11 statements  

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

1import typer 1abcdefgh

2 

3app = typer.Typer() 1abcdefgh

4 

5 

6def old_callback(): 1abcdefgh

7 """ 

8 Old callback help. 

9 """ 

10 

11 

12users_app = typer.Typer(callback=old_callback, name="users", help="Explicit help.") 1abcdefgh

13 

14 

15def new_users(): 1abcdefgh

16 """ 

17 I have the highland! Create some users. 

18 """ 

19 

20 

21app.add_typer(users_app, callback=new_users) 1abcdefgh

22 

23 

24@users_app.callback(help="Help from callback for users.") 1abcdefgh

25def users(): 1abcdefgh

26 """ 

27 Manage users in the app. 

28 """ 

29 

30 

31@users_app.command() 1abcdefgh

32def create(name: str): 1abcdefgh

33 print(f"Creating user: {name}") 1abcdefgh

34 

35 

36if __name__ == "__main__": 1abcdefgh

37 app() 1abcdefgh