From ff1f2c87602d9a5b58d20a29a68dfb5405b6d17e Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Tue, 10 Jun 2025 18:52:54 +1000 Subject: [PATCH] coding style: Can use the Popen context manager to close and wait --- eris/__main__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eris/__main__.py b/eris/__main__.py index 32cc11a..06d78f4 100755 --- a/eris/__main__.py +++ b/eris/__main__.py @@ -1112,14 +1112,11 @@ def manage_cache(root_path): @contextlib.contextmanager def print_to_pager(pager_command=["less", "-RFEX"]): try: - pager_process = subprocess.Popen(pager_command, stdin=subprocess.PIPE, text=True) + with subprocess.Popen(pager_command, stdin=subprocess.PIPE, text=True) as pager_process: + with contextlib.redirect_stdout(pager_process.stdin): + yield except FileNotFoundError: yield - else: - with contextlib.redirect_stdout(pager_process.stdin): - yield - pager_process.stdin.close() - pager_process.wait() def print_tool_info():