diff --git a/poetry/utils/inspector.py b/poetry/utils/inspector.py index 767f0946542..f1675273b47 100644 --- a/poetry/utils/inspector.py +++ b/poetry/utils/inspector.py @@ -3,8 +3,6 @@ import tarfile import zipfile -from bz2 import BZ2File -from gzip import GzipFile from typing import Dict from typing import List from typing import Union @@ -114,27 +112,21 @@ def inspect_sdist( # Still not dependencies found # So, we unpack and introspect suffix = file_path.suffix - gz = None if suffix == ".zip": tar = zipfile.ZipFile(str(file_path)) else: if suffix == ".bz2": - gz = BZ2File(str(file_path)) suffixes = file_path.suffixes if len(suffixes) > 1 and suffixes[-2] == ".tar": suffix = ".tar.bz2" else: - gz = GzipFile(str(file_path)) suffix = ".tar.gz" - tar = tarfile.TarFile(str(file_path), fileobj=gz) + tar = tarfile.open(str(file_path)) try: tar.extractall(os.path.join(str(file_path.parent), "unpacked")) finally: - if gz: - gz.close() - tar.close() unpacked = file_path.parent / "unpacked"