from typing import Optional


def _create_noncompat_join_key_types_errmsg(
    left_key_name: str,
    left_key_type: type,
    right_key_name: str,
    right_key_type: type,
    reason: Optional[str] = None
) -> str:
    """Create an error message for two column types which are not compatible as join-keys."""

    # If the caller didn't supply a reason, provide a generic explanation
    # that's (maybe) still helpful for new users.
    _reason = reason if reason is not None else "You may need to convert one of them into a different type before joining."

    return f'The columns \'{left_key_name}\' ({left_key_type}) and \'{right_key_name}\' ({right_key_type}) are not compatible for use as join-keys. {_reason}'