fix: close the file read_text() opens

read_text() returned open(...).read() without closing the file, which
left it to garbage collection and raised a ResourceWarning in the test
run. Read it inside a with block; the encoding stays utf-8.
This commit is contained in:
Mike Mulligan committed 2026-10-01 07:53:01 -04:00
1 parent 57910d9c86
commit 42625f4b23
1 file changed
+4 -1
+4 -1
View File
@@ -134,7 +134,10 @@ def resolve_in_repo(repo_root: str, rel: str):
def read_text(repo_root: str, name: str):
p = os.path.join(repo_root, name)
return open(p, encoding="utf-8").read() if os.path.isfile(p) else None
if not os.path.isfile(p):
return None
with open(p, encoding="utf-8") as fh:
return fh.read()
def parse_readme_sections(repo_root: str) -> dict: