from abc import ABC from dataclasses import replace from typing import Self from domain.marketplace.domain_event import DomainEvent class Entity(ABC): _events: tuple[DomainEvent, ...] = () def raise_event(self, event: DomainEvent) -> Self: return replace(self, _events=(*self._events, event)) def get_changes(self) -> tuple[DomainEvent, ...]: return self._events def clear_changes(self) -> Self: return replace(self, _events=())