From 5b67d149dd32cb92c6e9b9b1e551007002e6f02e Mon Sep 17 00:00:00 2001 From: alexanderschmitz Date: Mon, 20 Nov 2023 16:51:34 +0100 Subject: [PATCH] fix: enforce explicit FormModel Subclasses in BaseQuestionState --- questionpy/_qtype.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/questionpy/_qtype.py b/questionpy/_qtype.py index c68460e5..512f0986 100644 --- a/questionpy/_qtype.py +++ b/questionpy/_qtype.py @@ -113,6 +113,8 @@ def export_question_state(self) -> str: def __init_subclass__(cls, **kwargs: object) -> None: super().__init_subclass__(**kwargs) cls.state_class = _get_type_arg(cls, Question, 0, bound=BaseQuestionState, default=BaseQuestionState) + if _get_type_arg(cls, Question, 0) == BaseQuestionState: + raise TypeError(f"{cls.state_class.__name__} must declare a specific FormModel.") cls.attempt_class = _get_type_arg(cls, Question, 1, bound=Attempt)