Coverage for docs_src / parameter_types / enum / tutorial003_an_py39.py: 100%

11 statements  

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

1from enum import Enum 1abcdefgh

2from typing import Annotated 1abcdefgh

3 

4import typer 1abcdefgh

5 

6 

7class Food(str, Enum): 1abcdefgh

8 food_1 = "Eggs" 1abcdefgh

9 food_2 = "Bacon" 1abcdefgh

10 food_3 = "Cheese" 1abcdefgh

11 

12 

13app = typer.Typer() 1abcdefgh

14 

15 

16@app.command() 1abcdefgh

17def main(groceries: Annotated[list[Food], typer.Option()] = [Food.food_1, Food.food_3]): 1abcdefgh

18 print(f"Buying groceries: {', '.join([f.value for f in groceries])}") 1abcdefgh

19 

20 

21if __name__ == "__main__": 1abcdefgh

22 app() 1abcdefgh