From b90fc735fa9d0f8e86798104e4eb169a70b73dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:23:22 -0400 Subject: [PATCH] style: Fix replace-stdout-stderr (UP022) (#4000) Using `ruff check --output-format=concise --preview --select UP022 --unsafe-fixes --fix` --- pyproject.toml | 1 - python/grass/gunittest/invoker.py | 3 +-- utils/generate_last_commit_file.py | 3 +-- utils/mkhtml.py | 3 +-- utils/test_generate_last_commit_file.py | 3 +-- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 94fc0ae7564..e0b0ad7ce89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -561,7 +561,6 @@ ignore = [ "TRY302", # useless-try-except "UP015", # redundant-open-modes "UP018", # native-literals - "UP022", # replace-stdout-stderr "UP030", # format-literals "UP031", # printf-string-formatting "UP032", # f-string diff --git a/python/grass/gunittest/invoker.py b/python/grass/gunittest/invoker.py index 8fb0f62dae9..0b6350c9769 100644 --- a/python/grass/gunittest/invoker.py +++ b/python/grass/gunittest/invoker.py @@ -259,8 +259,7 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, timeout=timeout, check=False, ) diff --git a/utils/generate_last_commit_file.py b/utils/generate_last_commit_file.py index 69b1851d204..c6eddc9a094 100644 --- a/utils/generate_last_commit_file.py +++ b/utils/generate_last_commit_file.py @@ -65,8 +65,7 @@ def get_last_commit(src_dir): f"--format=%H,{COMMIT_DATE_FORMAT}", rel_path, ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, ) # --format=%H,COMMIT_DATE_FORMAT commit hash,author date if process_result.returncode == 0: try: diff --git a/utils/mkhtml.py b/utils/mkhtml.py index 5ac68ff66a7..aea0e922645 100644 --- a/utils/mkhtml.py +++ b/utils/mkhtml.py @@ -1026,8 +1026,7 @@ def has_src_code_git(src_dir, is_addon): f"--format=%H,{COMMIT_DATE_FORMAT}", src_dir, ], - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, + capture_output=True, ) # --format=%H,COMMIT_DATE_FORMAT commit hash,author date os.chdir(actual_dir) return process_result if process_result.returncode == 0 else None diff --git a/utils/test_generate_last_commit_file.py b/utils/test_generate_last_commit_file.py index f6e08389f22..3183b786c78 100644 --- a/utils/test_generate_last_commit_file.py +++ b/utils/test_generate_last_commit_file.py @@ -83,8 +83,7 @@ def test_compare_json_file_data(read_json_file, core_module_path): f"--format=%H,{COMMIT_DATE_FORMAT}", core_module_path, ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=True, ) # --format=%H,COMMIT_DATE_FORMAT commit hash,author date commit, date = process_result.stdout.decode().strip().split(",")