From 365725ad9f4a81f695a26480cf3ba50244c1e35b Mon Sep 17 00:00:00 2001 From: Ashnaa Seth Date: Thu, 26 Mar 2026 03:36:46 +0000 Subject: [PATCH] util: close devnull fd in is_git_repo Signed-off-by: Ashnaa Seth --- flow/util/genMetrics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/flow/util/genMetrics.py b/flow/util/genMetrics.py index fbf746cdfc..938a4c91fb 100755 --- a/flow/util/genMetrics.py +++ b/flow/util/genMetrics.py @@ -175,10 +175,11 @@ def read_sdc(file_name): def is_git_repo(folder=None): cmd = ["git", "branch"] - if folder is not None: - return call(cmd, stderr=STDOUT, stdout=open(os.devnull, "w"), cwd=folder) == 0 - else: - return call(cmd, stderr=STDOUT, stdout=open(os.devnull, "w")) == 0 + with open(os.devnull, "w") as devnull: + if folder is not None: + return call(cmd, stderr=STDOUT, stdout=devnull, cwd=folder) == 0 + else: + return call(cmd, stderr=STDOUT, stdout=devnull) == 0 def merge_jsons(root_path, output, files):