1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
from typing import Annotated from pydantic.functional_validators import AfterValidator IDLE = 'IDLE' MINING = 'MINING' MIA = 'MIA' ERROR = 'ERROR' task_types = [ IDLE, MINING, ] def is_task_type(task: str): assert task in task_types, f"'{task}' is not a valid task type." return task task_type = Annotated[str, AfterValidator(is_task_type)]