from typing import Optional from dataclasses import dataclass from uuid import uuid4 # A loop Habit representation. Tracks anything whose value can be encapsulated in a numerical value. @dataclass class Habit: name: str type: Optional[int] = 0 # 1 is range counter archived: Optional[int] = 0 color: Optional[int] = 0 highlight: Optional[int] = 0 freq_den: Optional[int] = 1 freq_num: Optional[int] = 1 target_value: Optional[int] = 0 description: Optional[str] = "" question: Optional[str] = "" unit: Optional[str] = "" position: Optional[int] = 0 uuid: Optional[str] = None # TODO test post init uuid setting def __post_init__(self): if not self.uuid: self.uuid = uuid4().hex