From d509a27ad4e462181719f25c32ba64c2c34b68de Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 22 Dec 2020 15:21:17 +0200 Subject: [PATCH] Review updates --- src/pip/_internal/operations/prepare.py | 12 ++++--- src/pip/_internal/pyproject.py | 4 +-- src/pip/_internal/utils/compat.py | 48 ++++--------------------- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index cc9c129b2..f1321709b 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -166,11 +166,13 @@ def _copy_source_tree(source, target): skipped += [target_basename] return skipped - kwargs = dict(ignore=ignore, symlinks=True) # type: CopytreeKwargs - - kwargs['copy_function'] = _copy2_ignoring_special_files - - shutil.copytree(source, target, **kwargs) + shutil.copytree( + source, + target, + ignore=ignore, + symlinks=True, + copy_function=_copy2_ignoring_special_files, + ) def get_file_url( diff --git a/src/pip/_internal/pyproject.py b/src/pip/_internal/pyproject.py index 97fdff766..ee90de12e 100644 --- a/src/pip/_internal/pyproject.py +++ b/src/pip/_internal/pyproject.py @@ -24,9 +24,7 @@ def _is_list_of_str(obj): def make_pyproject_path(unpacked_source_directory): # type: (str) -> str - path = os.path.join(unpacked_source_directory, 'pyproject.toml') - - return path + return os.path.join(unpacked_source_directory, 'pyproject.toml') BuildSystemDetails = namedtuple('BuildSystemDetails', [ diff --git a/src/pip/_internal/utils/compat.py b/src/pip/_internal/utils/compat.py index b0ff63f51..0115c307d 100644 --- a/src/pip/_internal/utils/compat.py +++ b/src/pip/_internal/utils/compat.py @@ -190,47 +190,13 @@ WINDOWS = (sys.platform.startswith("win") or (sys.platform == 'cli' and os.name == 'nt')) -if hasattr(shutil, 'get_terminal_size'): - def get_terminal_size(): - # type: () -> Tuple[int, int] - """ - Returns a tuple (x, y) representing the width(x) and the height(y) - in characters of the terminal window. - """ - return tuple(shutil.get_terminal_size()) # type: ignore -else: - def get_terminal_size(): - # type: () -> Tuple[int, int] - """ - Returns a tuple (x, y) representing the width(x) and the height(y) - in characters of the terminal window. - """ - def ioctl_GWINSZ(fd): - try: - import fcntl - import struct - import termios - cr = struct.unpack_from( - 'hh', - fcntl.ioctl(fd, termios.TIOCGWINSZ, '12345678') - ) - except Exception: - return None - if cr == (0, 0): - return None - return cr - cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) - if not cr: - if sys.platform != "win32": - try: - fd = os.open(os.ctermid(), os.O_RDONLY) - cr = ioctl_GWINSZ(fd) - os.close(fd) - except Exception: - pass - if not cr: - cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80)) - return int(cr[1]), int(cr[0]) +def get_terminal_size(): + # type: () -> Tuple[int, int] + """ + Returns a tuple (x, y) representing the width(x) and the height(y) + in characters of the terminal window. + """ + return tuple(shutil.get_terminal_size()) # type: ignore # Fallback to noop_lru_cache in Python 2