from pathlib import Path from aiopath import AsyncPath def validate_file_folder(value: str) -> Path: file_folder_path = Path(value) if not file_folder_path.exists(): raise FileNotFoundError(f"No such file or folder: {value}") if not file_folder_path.is_file() and not file_folder_path.is_dir(): raise TypeError(f"Not a file or directory: {value}") return AsyncPath(value)