Skip to content

Commit 365725a

Browse files
util: close devnull fd in is_git_repo
Signed-off-by: Ashnaa Seth <ashnaaseth2325@gmail.com>
1 parent 7fd4e25 commit 365725a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

flow/util/genMetrics.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ def read_sdc(file_name):
175175

176176
def is_git_repo(folder=None):
177177
cmd = ["git", "branch"]
178-
if folder is not None:
179-
return call(cmd, stderr=STDOUT, stdout=open(os.devnull, "w"), cwd=folder) == 0
180-
else:
181-
return call(cmd, stderr=STDOUT, stdout=open(os.devnull, "w")) == 0
178+
with open(os.devnull, "w") as devnull:
179+
if folder is not None:
180+
return call(cmd, stderr=STDOUT, stdout=devnull, cwd=folder) == 0
181+
else:
182+
return call(cmd, stderr=STDOUT, stdout=devnull) == 0
182183

183184

184185
def merge_jsons(root_path, output, files):

0 commit comments

Comments
 (0)