def METHOD_NAME(S: str, max: int, ellipsis: str | bool = '...') -> str:
    """Abbreviate word."""
    if S is None:
        return '???'
    if len(S) > max:
        return isinstance(ellipsis, str) and (
            S[: max - len(ellipsis)] + ellipsis) or S[: max]
    return S