From 9896bfb76547c1030144bca9d1508e0f8093c864 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sun, 12 Jan 2025 07:37:35 -0800 Subject: [PATCH] Fixed SIM117 (multiple-with-statements): Use a single `with` statement with multiple contexts instead of nested `with` statements --- management/mail_log.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/management/mail_log.py b/management/mail_log.py index c15c444a..1a601d25 100755 --- a/management/mail_log.py +++ b/management/mail_log.py @@ -72,9 +72,8 @@ def scan_files(collector): if not os.path.exists(fn): continue if fn[-3:] == '.gz': - with tempfile.NamedTemporaryFile(delete=False) as tmp_file: - with gzip.open(fn, 'rb') as f: - shutil.copyfileobj(f, tmp_file) + with tempfile.NamedTemporaryFile(delete=False) as tmp_file, gzip.open(fn, 'rb') as f: + shutil.copyfileobj(f, tmp_file) if VERBOSE: print("Processing file", fn, "...")