Skip to content

Commit 7e3609f

Browse files
committed
chore(file_operators): use utf-8 as default encoding
1 parent 94e2ab7 commit 7e3609f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

app/tool/file_operators.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ async def run_command(
4242
class LocalFileOperator(FileOperator):
4343
"""File operations implementation for local filesystem."""
4444

45+
def __init__(self, encoding: str = "utf-8"):
46+
self.encoding = encoding
47+
4548
async def read_file(self, path: PathLike) -> str:
4649
"""Read content from a local file."""
4750
try:
48-
return Path(path).read_text()
51+
return Path(path).read_text(encoding=self.encoding)
4952
except Exception as e:
5053
raise ToolError(f"Failed to read {path}: {str(e)}") from None
5154

5255
async def write_file(self, path: PathLike, content: str) -> None:
5356
"""Write content to a local file."""
5457
try:
55-
Path(path).write_text(content)
58+
Path(path).write_text(content, encoding=self.encoding)
5659
except Exception as e:
5760
raise ToolError(f"Failed to write to {path}: {str(e)}") from None
5861

0 commit comments

Comments
 (0)