from pathlib import Path


def ensure_path(path):
    """Ensure `path` is an Path object (or None)."""
    if path is None:
        return path
    if not isinstance(path, Path):
        path = Path(path)
    return path