Skip to content

Instantly share code, notes, and snippets.

@msf
Forked from marcelolebre/value_nesting.py
Last active January 13, 2020 18:27
Show Gist options
  • Save msf/83a637b3e5142bc3e6c3a956bf0242fe to your computer and use it in GitHub Desktop.
Save msf/83a637b3e5142bc3e6c3a956bf0242fe to your computer and use it in GitHub Desktop.
@dataclass
class User:
username: str
email: str
first_name: str
last_name: str
@classmethod
def from_db(cls, db_user):
return cls(
username=db_user.username,
email=db_user.email,
first_name=db_user.first_name,
last_name=db_user.last_name,
)
@dataclass
class Editor:
average_rating: float
language_pairs: List[str]
@dataclass
class Profile:
user: User
editor: Editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment