Allow nullish zip_path for convenience

This commit is contained in:
Aarni Koskela 2025-04-25 14:00:47 +03:00
parent dc175f3d14
commit ca2f96d75e

View File

@ -6,7 +6,9 @@ from zipfile import ZipFile
class ZipUtil:
@staticmethod
def unzip(zip_path: str | Path, filename: str, loader: callable):
def unzip(zip_path: str | Path | None, filename: str, loader: callable):
if not zip_path: # Would be nicer to do this in typing, but that's more effort on the callers' side
raise ValueError("zip_path cannot be None")
zip_path = Path(zip_path)
if not zip_path.exists():
raise FileNotFoundError(f"ZIP file not found at: {zip_path}")