from pathlib import Path def ensure_dir(path: str | Path) -> Path: output = Path(path) output.mkdir(parents=True, exist_ok=True) return output