Skip to content

Commit 63b9137

Browse files
authored
Merge pull request rllm-org#122 from bact/open-with-encoding
Fix pylint W1514 warning of using open without encoding
2 parents 09f8f9f + e2d50ef commit 63b9137

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/listing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def readme_contents(file: Path, key: str) -> Contents:
5353

5454
# Read the file lines
5555
readme_lines = []
56-
with open(file, "r") as readme_file:
56+
with open(file, "r", encoding="utf-8") as readme_file:
5757
readme_lines = readme_file.readlines()
5858

5959
# Go through line by line and collect the prefix and suffix
@@ -84,7 +84,7 @@ def rewrite_task_readme(path: str, key: str, contents: list[str]) -> None:
8484
readme_path = Path(__file__).parent / ".." / path / "README.md"
8585
parsed = readme_contents(readme_path, key)
8686
if parsed.contains_key:
87-
with open(readme_path, "w") as readme_file:
87+
with open(readme_path, "w", encoding="utf-8") as readme_file:
8888
readme_file.write("\n".join(parsed.prefix + contents + parsed.suffix))
8989

9090

@@ -180,7 +180,7 @@ def generate_readme() -> None:
180180

181181
# read the listings
182182
listings_raw: list[dict[str, Any]] = []
183-
with open(listing_file, "r") as yaml_file:
183+
with open(listing_file, "r", encoding="utf-8") as yaml_file:
184184
listings_raw = yaml.safe_load(yaml_file)
185185

186186
# read them
@@ -213,7 +213,7 @@ def generate_readme() -> None:
213213
contents = readme_contents(readme_path, EVAL_KEY)
214214

215215
# rewrite the readme with prefix and suffix content
216-
with open(readme_path, "w") as readme_file:
216+
with open(readme_path, "w", encoding="utf-8") as readme_file:
217217
readme_file.write("\n".join(contents.prefix + content + contents.suffix))
218218

219219
for listing_raw in listings_raw:

0 commit comments

Comments
 (0)