def METHOD_NAME(
    username: Optional[str], password: Optional[str], host: str, port: Optional[int]
) -> str:
    if port:
        host_info = f"{host}:{port:d}"
    else:
        host_info = host
    if username:
        if password:
            user_info = f"{username}:{password}"
        else:
            user_info = username
    else:
        user_info = ""
    if user_info:
        return f"{user_info}@{host_info}"
    else:
        return host_info