from pathlib import Path


def ensure_dirpath_exists(path: Path) -> Path:
    """Utility to create a directory if missing.
    Returns the path so that the call can be inlined in a another call

    Args:
        path (Path): path to create
    Returns
        path of created directory
    """
    assert path
    out_path: Path = path

    if not out_path.exists():
        out_path.mkdir(parents=True, exist_ok=True)

    return out_path