Coverage for docs_src / parameter_types / path / tutorial001_non_an.py: 100%
15 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
3import typer 1abcdefghij
5app = typer.Typer() 1abcdefghij
8@app.command() 1abcdefghij
9def main(config: Path | None = typer.Option(None)): 1abcdefghij
10 if config is None: 1abcdefghij
11 print("No config file") 1abcdefghij
12 raise typer.Abort() 1abcdefghij
13 if config.is_file(): 1abcdefghij
14 text = config.read_text() 1abcdefghij
15 print(f"Config file contents: {text}") 1abcdefghij
16 elif config.is_dir(): 1abcdefghij
17 print("Config is a directory, will use all its config files") 1abcdefghij
18 elif not config.exists(): 1abcdefghij
19 print("The config doesn't exist") 1abcdefghij
22if __name__ == "__main__": 1abcdefghij
23 app() 1abcdefghij