Coverage for docs_src / parameter_types / path / tutorial002.py: 100%

8 statements  

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

1from pathlib import Path 1abcdefghij

2from typing import Annotated 1abcdefghij

3 

4import typer 1abcdefghij

5 

6app = typer.Typer() 1abcdefghij

7 

8 

9@app.command() 1abcdefghij

10def main( 1abcdefghij

11 config: Annotated[ 

12 Path, 

13 typer.Option( 

14 exists=True, 

15 file_okay=True, 

16 dir_okay=False, 

17 writable=False, 

18 readable=True, 

19 resolve_path=True, 

20 ), 

21 ], 

22): 

23 text = config.read_text() 1abcdefghij

24 print(f"Config file contents: {text}") 1abcdefghij

25 

26 

27if __name__ == "__main__": 1abcdefghij

28 app() 1abcdefghij