mirror of
https://github.com/EbookFoundation/free-programming-books.git
synced 2026-07-08 13:21:55 +00:00
Fix: Use context manager for file reads (with open(...) as f)
This commit is contained in:
parent
39332e76ce
commit
6bf42edf13
@ -210,7 +210,8 @@ def lint_file(path, cfg):
|
||||
|
||||
# Try to read the file content and handle potential errors
|
||||
try:
|
||||
lines = open(path, encoding='utf-8').read().splitlines()
|
||||
with open(path, encoding='utf-8') as f:
|
||||
lines = f.read().splitlines()
|
||||
except Exception as e:
|
||||
return [f"::error file={path},line=1::Cannot read file: {e}"] # Return as a list of issues
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user