From 5d439c0f3820bbd8bd997640bdf70bcbb6512294 Mon Sep 17 00:00:00 2001 From: Robert Martin Date: Wed, 25 May 2022 18:04:54 -0600 Subject: [PATCH] Fix a Pylint warning --- cibuildwheel/docker_container.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 583eb3d52..9dc3ab70d 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -128,7 +128,7 @@ def copy_into(self, from_path: Path, to_path: PurePath) -> None: cwd=from_path, ) else: - docker = subprocess.Popen( + with subprocess.Popen( [ "docker", "exec", @@ -139,17 +139,17 @@ def copy_into(self, from_path: Path, to_path: PurePath) -> None: f"cat > {shell_quote(to_path)}", ], stdin=subprocess.PIPE, - ) - docker.stdin = cast(IO[bytes], docker.stdin) + ) as docker: + docker.stdin = cast(IO[bytes], docker.stdin) - with open(from_path, "rb") as from_file: - shutil.copyfileobj(from_file, docker.stdin) + with open(from_path, "rb") as from_file: + shutil.copyfileobj(from_file, docker.stdin) - docker.stdin.close() - docker.wait() + docker.stdin.close() + docker.wait() - if docker.returncode: - raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) + if docker.returncode: + raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) def copy_out(self, from_path: PurePath, to_path: Path) -> None: # note: we assume from_path is a dir