Skip to content

Commit 16be276

Browse files
maldilmufiAmazon
authored andcommitted
refactoring : using with statement (aws#3286)
1 parent e608801 commit 16be276

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/sagemaker/git_utils.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,8 @@ def _run_clone_command(repo_url, dest_dir):
279279
subprocess.check_call(["git", "clone", repo_url, dest_dir], env=my_env)
280280
elif repo_url.startswith("git@"):
281281
with tempfile.NamedTemporaryFile() as sshnoprompt:
282-
write_pipe = open(sshnoprompt.name, "w")
283-
write_pipe.write("ssh -oBatchMode=yes $@")
284-
write_pipe.close()
282+
with open(sshnoprompt.name, "w") as write_pipe:
283+
write_pipe.write("ssh -oBatchMode=yes $@")
285284
os.chmod(sshnoprompt.name, 0o511)
286285
my_env["GIT_SSH"] = sshnoprompt.name
287286
subprocess.check_call(["git", "clone", repo_url, dest_dir], env=my_env)

0 commit comments

Comments
 (0)