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

11 statements  

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

1from enum import StrEnum 1abcdefghij

2from typing import Annotated 1abcdefghij

3 

4import typer 1abcdefghij

5 

6 

7class Food(StrEnum): 1abcdefghij

8 food_1 = "Eggs" 1abcdefghij

9 food_2 = "Bacon" 1abcdefghij

10 food_3 = "Cheese" 1abcdefghij

11 

12 

13app = typer.Typer() 1abcdefghij

14 

15 

16@app.command() 1abcdefghij

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

18 print(f"Buying groceries: {', '.join(groceries)}") 1abcdefghij

19 

20 

21if __name__ == "__main__": 1abcdefghij

22 app() 1abcdefghij