human
I am working on the file "20210325-Ubitalk-Python/Modern Python Programming.ipynb".
The first task is:
Type Annotations
Not just for documentation
Can you write Python code for it?

Write me a the Python code you requested?
assistant
#Here is the Python code you requested.

from abc import ABC, abstractmethod
from pydantic import BaseModel
from typing import Tuple, Optional
from datetime import date

class IdMixin(BaseModel):
    id: int
        
class UserCommon(BaseModel):
    name: str
    email: str
    birthday: Optional[date] = None
        
class UserCreate(UserCommon):
    pass

class UserInDB(IdMixin, UserCommon):
    pass

class Backend(ABC):
    @abstractmethod
    def get_user_by_mail(self, email: str) -> Optional[UserInDB]:
        pass
    
    @abstractmethod
    def create_user(self, user_create: UserCreate) -> UserInDB:
        pass

# Before type annotations

def register_user(data, backend, today):
    existing_user = backend.get_user_by_email(data["email"])
    if existing_user:
        raise ValueError("Email already used.")
    else:
        user = backend.create_user(data)
        if user.birthday == today:
            welcome_message = f"Happy Birthday, {user.name}!"
        else:
            welcome_message = f"Welcome, {user.name}!"
        return user, welcome_message

WelcomeMessage = str
    
def register_user(user_create: UserCreate, backend: Backend, today: date) -> Tuple[UserInDB, WelcomeMessage]:
    existing_user = backend.get_user_by_email(user_create.email)
    if existing_user:
        raise ValueError("Email already used.")
    else:
        user = backend.create_user(user_create)
        if user.birthday == today:
            welcome_message = f"Happy Birthday, {user.name}!"
        else:
            welcome_message = f"Welcome, {user.name}!"
        return user, welcome_message
    

from pydantic import BaseModel
from typing import Tuple, Optional
from datetime import date

class IdMixin(BaseModel):
    id: int
        
class UserCommon(BaseModel):
    name: str
    email: str
    birthday: Optional[date] = None
        
class UserCreate(UserCommon):
    pass

class UserInDB(IdMixin, UserCommon):
    pass

from abc import ABC, abstractmethod
from typing import Optional

class Backend(ABC):
    @abstractmethod
    def...