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

10 statements  

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

1from enum import Enum 1abcdefgh

2 

3import typer 1abcdefgh

4 

5 

6class Food(str, Enum): 1abcdefgh

7 food_1 = "Eggs" 1abcdefgh

8 food_2 = "Bacon" 1abcdefgh

9 food_3 = "Cheese" 1abcdefgh

10 

11 

12app = typer.Typer() 1abcdefgh

13 

14 

15@app.command() 1abcdefgh

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

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

18 

19 

20if __name__ == "__main__": 1abcdefgh

21 app() 1abcdefgh