I want to use a state machine in my SQLModel schema but I'm getting type errors.
class Invoice(BaseSQLModel, table=True):
id: Optional[int] = Field(primary_key=True)
def __init__(self):
super().__init__()
default_status = fsm.initial_payment_state
self.fsm = fsm.get_payment_fsm(default_status). # Throws an error here because fsm is not an attribute of the class
Is it possible to declare an attribute which is ignored when creating columns? How can I declare the fsm and state attributes here?
I've tried this but then the code gets stuck when trying to call fsm.add_model(self)
class Invoice(BaseSQLModel, table=True):
id: Optional[int] = Field(primary_key=True)
_fsm: "Machine" = PrivateAttr()
def __init__(self):
super().__init__()
default_status = fsm.initial_payment_state
self._fsm = fsm.get_payment_fsm(default_status)
self._fsm.add_model(self). # Gets stuck here
# Allowing me to declare additional attributes
class Config:
extra = Extra.allow
arbitrary_types_allowed = True