Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
address PR comments
0divbd4398f30d8f
diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.pyindex c3ce62785..318db5e6c 100644--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py@@ -1,6 +1,6 @@import httpcoreimport httpx-from io import TextIOBase, BufferedReader+from io import IOBasefrom packaging.version import Versionfrom typing import AsyncIterator, IO, List, Literal, Optional, overload, Unionfrom e2b.sandbox.filesystem.filesystem import WriteEntry@@ -206,7 +206,7 @@ class Filesystem:file_path, file_data = file['path'], file['data']if isinstance(file_data, str) or isinstance(file_data, bytes):httpx_files.append(('file', (file_path, file_data)))- elif isinstance(file_data, TextIOBase) or isinstance(file_data, BufferedReader):+ elif isinstance(file_data,IOBase):httpx_files.append(('file', (file_path, file_data.read())))else:raise ValueError(f"Unsupported data type for file {file_path}")diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.pyindex ae796e33d..0cefd7b5a 100644--- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py@@ -1,4 +1,4 @@-from io import TextIOBase, BufferedReader+from io import IOBasefrom typing import IO, Iterator, List, Literal, Optional, overload, Unionfrom e2b.sandbox.filesystem.filesystem import WriteEntry@@ -202,7 +202,7 @@ class Filesystem:file_path, file_data = file['path'], file['data']if isinstance(file_data, str) or isinstance(file_data, bytes):httpx_files.append(('file', (file_path, file_data)))- elif isinstance(file_data, TextIOBase) or isinstance(file_data, BufferedReader):+ elif isinstance(file_data, IOBase):httpx_files.append(('file', (file_path, file_data.read())))else:raise ValueError(f"Unsupported data type for file {file_path}")diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_write.py b/packages/python-sdk/tests/async/sandbox_async/files/test_write.pyindex 14894701a..0e91c11c9 100644--- a/packages/python-sdk/tests/async/sandbox_async/files/test_write.py+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_write.py@@ -26,7 +26,7 @@ async def test_write_binary_file(async_sandbox: AsyncSandbox):filename = "test_write.txt"text = "This is a test binary file."# equivalent to `open("path/to/local/file", "rb")`- content = io.BufferedReader(io.BytesIO(text.encode("utf-8")))+ content = io.BytesIO(text.encode('utf-8'))info = await async_sandbox.files.write(filename, content)assert info.path == f"/home/user/{filename}"diff --git a/packages/python-sdk/tests/sync/sandbox_sync/files/test_write.py b/packages/python-sdk/tests/sync/sandbox_sync/files/test_write.pyindex 3eefd6c13..263b2fd0c 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/files/test_write.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/files/test_write.py@@ -25,7 +25,7 @@ def test_write_binary_file(sandbox):filename = "test_write.txt"text = "This is a test binary file."# equivalent to `open("path/to/local/file", "rb")`- content = io.BufferedReader(io.BytesIO(text.encode("utf-8")))+ content = io.BytesIO(text.encode('utf-8'))info = sandbox.files.write(filename, content)assert info.path == f"/home/user/{filename}"