From 16051ff104188c40cf550c2a7b66fdb229fc27d9 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Thu, 9 Jun 2022 03:47:47 +0300 Subject: [PATCH] Type annotate zipfile.unzip --- cookiecutter/zipfile.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cookiecutter/zipfile.py b/cookiecutter/zipfile.py index 241944e62..bab90a264 100644 --- a/cookiecutter/zipfile.py +++ b/cookiecutter/zipfile.py @@ -1,6 +1,8 @@ """Utility functions for handling and fetching repo archives in zip format.""" import os import tempfile +from pathlib import Path +from typing import Optional from zipfile import BadZipFile, ZipFile import requests @@ -10,7 +12,13 @@ from cookiecutter.utils import make_sure_path_exists, prompt_and_delete -def unzip(zip_uri, is_url, clone_to_dir='.', no_input=False, password=None): +def unzip( + zip_uri: str, + is_url: bool, + clone_to_dir: "os.PathLike[str]" = ".", + no_input: bool = False, + password: Optional[str] = None, +): """Download and unpack a zipfile at a given URI. This will download the zipfile to the cookiecutter repository, @@ -25,7 +33,7 @@ def unzip(zip_uri, is_url, clone_to_dir='.', no_input=False, password=None): :param password: The password to use when unpacking the repository. """ # Ensure that clone_to_dir exists - clone_to_dir = os.path.expanduser(clone_to_dir) + clone_to_dir = Path(clone_to_dir).expanduser() make_sure_path_exists(clone_to_dir) if is_url: