Skip to content

Commit 69d32b9

Browse files
committed
Refactor open() call to always close the file
otherwise we get an alert from CodeQL
1 parent c6fcf90 commit 69d32b9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

setup.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55

66
def get_version():
7-
version = open(os.path.join("tcms_api", "version.py")).read()
8-
return (
9-
version.replace(" ", "")
10-
.replace("__version__=", "")
11-
.strip()
12-
.strip("'")
13-
.strip('"')
14-
)
7+
with open(os.path.join("tcms_api", "version.py"), "r") as file:
8+
version = file.read()
9+
10+
return (
11+
version.replace(" ", "")
12+
.replace("__version__=", "")
13+
.strip()
14+
.strip("'")
15+
.strip('"')
16+
)
1517

1618

1719
def get_install_requires(path):

0 commit comments

Comments
 (0)