Coverage for docs_src / parameter_types / path / tutorial001.py: 100%
16 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« 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
4import typer 1abcdefghij
6app = typer.Typer() 1abcdefghij
9@app.command() 1abcdefghij
10def main(config: Annotated[Path | None, typer.Option()] = None): 1abcdefghij
11 if config is None: 1abcdefghij
12 print("No config file") 1abcdefghij
13 raise typer.Abort() 1abcdefghij
14 if config.is_file(): 1abcdefghij
15 text = config.read_text() 1abcdefghij
16 print(f"Config file contents: {text}") 1abcdefghij
17 elif config.is_dir(): 1abcdefghij
18 print("Config is a directory, will use all its config files") 1abcdefghij
19 elif not config.exists(): 1abcdefghij
20 print("The config doesn't exist") 1abcdefghij
23if __name__ == "__main__": 1abcdefghij
24 app() 1abcdefghij