from typing import Union
import pathlib
from pathlib import Path


def strip_ext(filepath: Union[str, pathlib.Path]) -> Union[str, pathlib.Path]:
    """
    Strip extension from a file.

    Parameters
    ----------
    filepath : str or pathlib.Path

    Returns
    -------
    str or pathlib.PosixPath
        `filepath` with suffix removed. type is equivalent to input.

    """
    result = Path(filepath).with_suffix('')
    return result if isinstance(filepath, Path) else str(result)