Created
August 29, 2018 14:36
-
-
Save konradhalas/03b7f0863e29fa1028cf8160a1dff77c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ugly | |
def register_user(user_data): | |
... | |
save_user_in_db( | |
email=user_data['email'], | |
first_name=user_data['first_name'], | |
... | |
) | |
# beautiful | |
from dataclasses import dataclass | |
@dataclass | |
class UserRegistrationData: | |
email: str | |
first_name: str | |
... | |
def register_user(user_data: UserRegistrationData) -> None: | |
... | |
save_user_in_db( | |
email=user_data.email, | |
first_name=user_data.first_name, | |
... | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment