Skip to content

Instantly share code, notes, and snippets.

@gkocjan gkocjan/ca_python_entities.py Secret
Last active Sep 26, 2019

Embed
What would you like to do?
ca_python_entities.py
from dataclasses import dataclass, field
from datetime import datetime
from typing import List
@dataclass(frozen=True)
class Client(BaseEntity):
id: int
name: str
@dataclass(frozen=True)
class Product(BaseEntity):
id: int
name: str
price: float
@dataclass(frozen=True)
class Order(BaseEntity):
id: int
created: datetime
client: Client
total_cost: float = 0
items: List[Product] = field(default_factory=list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.