Skip to content

Instantly share code, notes, and snippets.

@gkocjan
Last active September 26, 2019 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkocjan/fa58d7ec01e97d238885ae6f5a14c329 to your computer and use it in GitHub Desktop.
Save gkocjan/fa58d7ec01e97d238885ae6f5a14c329 to your computer and use it in GitHub Desktop.
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