Coverage for docs_src/commands/callback/tutorial003.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-04-14 00:18 +0000

1import typer 1iabcdefgh

2 

3 

4def callback(): 1iabcdefgh

5 print("Running a command") 1iabcdefgh

6 

7 

8app = typer.Typer(callback=callback) 1iabcdefgh

9 

10 

11@app.callback() 1iabcdefgh

12def new_callback(): 1abcdefgh

13 print("Override callback, running a command") 1iabcdefgh

14 

15 

16@app.command() 1iabcdefgh

17def create(name: str): 1iabcdefgh

18 print(f"Creating user: {name}") 1iabcdefgh

19 

20 

21if __name__ == "__main__": 1iabcdefgh

22 app() 1iabcdefgh