Coverage for src / agent_contracts / config / questions.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-09 00:42 +0900

1"""Question schema definitions. 

2 

3Pydantic models for question definitions. 

4""" 

5from __future__ import annotations 

6 

7from typing import Literal 

8 

9from pydantic import BaseModel, Field 

10 

11 

12class QuestionOption(BaseModel): 

13 """Question choice option.""" 

14 label: str 

15 value: str 

16 

17 

18class QuestionDefinition(BaseModel): 

19 """Question definition schema (generic). 

20  

21 Used for defining structured questions in YAML. 

22  

23 Example YAML: 

24 my_question: 

25 id: my_question 

26 text: "What is your preference?" 

27 input_type: single_choice 

28 options: 

29 - { label: "Option A", value: "a" } 

30 - { label: "Option B", value: "b" } 

31 """ 

32 id: str 

33 text: str 

34 input_type: Literal["single_choice", "multi_choice", "text", "image_upload"] 

35 options: list[QuestionOption] = Field(default_factory=list) 

36 placeholder: str | None = None 

37 

38 

39# Type aliases 

40QuestionGroup = dict[str, QuestionDefinition] 

41QuestionsConfig = dict[str, QuestionGroup]