mirror of
https://github.com/offa/android-foss.git
synced 2026-07-21 17:35:38 +02:00
refactor: unclosed file handle for readme.md (#620)
The `README.md` file is opened using `open('README.md', 'r')` but is never explicitly closed. This can lead to resource leaks, especially in long-running processes or if the script were to be extended to open many files. While Python's garbage collector might eventually close it, it's not guaranteed and is considered bad practice.
Affected files: ensure_sorted.py
Signed-off-by: toanmap <174589430+maptoan@users.noreply.github.com>
This commit is contained in:
+2
-2
@@ -54,10 +54,10 @@ class Category:
|
|||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
readme_file = open('README.md', 'r')
|
|
||||||
# start of the Apps section
|
# start of the Apps section
|
||||||
APPS_LINE_START = '## – Apps –\n'
|
APPS_LINE_START = '## – Apps –\n'
|
||||||
lines = readme_file.readlines()
|
with open('README.md', 'r') as readme_file:
|
||||||
|
lines = readme_file.readlines()
|
||||||
|
|
||||||
index: int
|
index: int
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user