Type annotations for pip._internal.utils.unpacking

This commit is contained in:
Devesh Kumar Singh 2020-05-20 23:13:00 +05:30
parent e9901982bf
commit d84c14013a
1 changed files with 6 additions and 6 deletions

View File

@ -1,10 +1,6 @@
"""Utilities related archives.
"""
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
# mypy: disallow-untyped-defs=False
from __future__ import absolute_import
import logging
@ -48,6 +44,7 @@ except ImportError:
def current_umask():
# type: () -> int
"""Get the current umask which involves having to set it temporarily."""
mask = os.umask(0)
os.umask(mask)
@ -208,6 +205,7 @@ def untar_file(filename, location):
)
continue
else:
fp = None
try:
fp = tar.extractfile(member)
except (KeyError, AttributeError) as exc:
@ -220,8 +218,10 @@ def untar_file(filename, location):
continue
ensure_dir(os.path.dirname(path))
with open(path, 'wb') as destfp:
shutil.copyfileobj(fp, destfp)
fp.close()
if fp:
shutil.copyfileobj(fp, destfp)
if fp:
fp.close()
# Update the timestamp (useful for cython compiled files)
# https://github.com/python/typeshed/issues/2673
tar.utime(member, path) # type: ignore