Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
chore(python-sdk): drop Python 3.10 compatibility shims (#2004)
devin-ai-integration[bot]d7ed073584ad
diff --git a/.changeset/quiet-tigers-remove.md b/.changeset/quiet-tigers-remove.mdnew file mode 100644index 000000000..e23e26088--- /dev/null+++ b/.changeset/quiet-tigers-remove.md@@ -0,0 +1,7 @@+---+'@e2b/python-sdk': patch+'@e2b/code-interpreter-python': patch+'@e2b/desktop-python': patch+---++Remove Python 3.10 compatibility shims (Python >=3.11 is already required).diff --git a/packages/code-interpreter-python/e2b_code_interpreter/client.py b/packages/code-interpreter-python/e2b_code_interpreter/client.pyindex 47d286e34..2d43681ad 100644--- a/packages/code-interpreter-python/e2b_code_interpreter/client.py+++ b/packages/code-interpreter-python/e2b_code_interpreter/client.py@@ -1,9 +1,7 @@-from typing import Dict, Type, TypeVar, cast+from typing import Dict, Type, TypeVar, Unpack, castfrom e2b import ApiParams, E2BClientParamsfrom e2b import E2B as CoreE2B-from typing_extensions import Unpack-from e2b_code_interpreter.code_interpreter_async import AsyncSandboxfrom e2b_code_interpreter.code_interpreter_sync import Sandboxdiff --git a/packages/desktop-python/e2b_desktop/client.py b/packages/desktop-python/e2b_desktop/client.pyindex 55d859a01..e10a06138 100644--- a/packages/desktop-python/e2b_desktop/client.py+++ b/packages/desktop-python/e2b_desktop/client.py@@ -1,9 +1,7 @@-from typing import Dict, Type, TypeVar, cast+from typing import Dict, Type, TypeVar, Unpack, castfrom e2b import ApiParams, E2BClientParamsfrom e2b import E2B as CoreE2B-from typing_extensions import Unpack-from e2b_desktop.main import SandboxT = TypeVar("T")diff --git a/packages/desktop-python/e2b_desktop/main.py b/packages/desktop-python/e2b_desktop/main.pyindex ec81fec96..3ab7415bf 100644--- a/packages/desktop-python/e2b_desktop/main.py+++ b/packages/desktop-python/e2b_desktop/main.py@@ -2,7 +2,18 @@ import loggingimport timefrom re import search as re_searchfrom shlex import quote as quote_string-from typing import Callable, Dict, Iterator, Literal, Optional, overload, Tuple, Union+from typing import (+ Callable,+ Dict,+ Iterator,+ Literal,+ Optional,+ Self,+ Unpack,+ overload,+ Tuple,+ Union,+)from uuid import uuid4from e2b import (@@ -17,7 +28,6 @@ from e2b import (Volume,)from e2b.connection_config import ApiParams-from typing_extensions import Self, UnpackMOUSE_BUTTONS = {"left": 1, "right": 3, "middle": 2}diff --git a/packages/python-sdk/e2b/client.py b/packages/python-sdk/e2b/client.pyindex ada3965f0..d704e4816 100644--- a/packages/python-sdk/e2b/client.py+++ b/packages/python-sdk/e2b/client.py@@ -1,6 +1,4 @@-from typing import Dict, Type, TypeVar, cast--from typing_extensions import Unpack+from typing import Dict, Type, TypeVar, Unpack, castfrom e2b.connection_config import ApiParamsfrom e2b.sandbox_async.main import AsyncSandboxdiff --git a/packages/python-sdk/e2b/connection_config.py b/packages/python-sdk/e2b/connection_config.pyindex 6ad35b37f..efee15ec6 100644--- a/packages/python-sdk/e2b/connection_config.py+++ b/packages/python-sdk/e2b/connection_config.py@@ -1,11 +1,19 @@import loggingimport os-from typing import cast, Literal, Mapping, Optional, Dict, Tuple, TypedDict, Union+from typing import (+ cast,+ Literal,+ Mapping,+ Optional,+ Dict,+ Tuple,+ TypedDict,+ Union,+ Unpack,+)import httpx-from typing_extensions import Unpack-from e2b.exceptions import InvalidArgumentExceptionfrom e2b.retry import resolve_max_retriesfrom e2b.api.metadata import package_versiondiff --git a/packages/python-sdk/e2b/envd/client_async/__init__.py b/packages/python-sdk/e2b/envd/client_async/__init__.pyindex 8edf17f4c..00f2ce4ba 100644--- a/packages/python-sdk/e2b/envd/client_async/__init__.py+++ b/packages/python-sdk/e2b/envd/client_async/__init__.py@@ -124,24 +124,26 @@ async def first_event("""if not request_timeout:return await events.__anext__()+ task = asyncio.current_task()+ cancelling_before = task.cancelling() if task is not None else 0try:return await asyncio.wait_for(events.__anext__(), request_timeout)- except (asyncio.TimeoutError, TimeoutError) as e:+ except TimeoutError as e:raise _request_timeout_exception(request_timeout) from eexcept ConnectError as e:# wait_for's expiry cancels the __anext__ task, but connectrpc# converts the delivered CancelledError into ConnectError(CANCELED)# before wait_for can turn it into TimeoutError. A caller cancelling- # the surrounding task surfaces identically, so tell the two apart by- # the pending-cancellation count: wait_for uncancels its own expiry,- # an external cancel stays pending. (Python 3.10 has no cancelling(),- # but its wait_for re-raises external cancels before this point, so- # reaching here without it means the timer expired.)- cancelling = getattr(asyncio.current_task(), "cancelling", None)+ # the surrounding task surfaces identically, so compare the pending-+ # cancellation count with its entry value: wait_for uncancels its own+ # expiry back to that value, while an external cancel leaves it above+ # it. Comparing against zero would misclassify a timer expiry when the+ # caller had an already-pending, swallowed cancellation.if (e.code is Code.CANCELEDand isinstance(e.__cause__, asyncio.CancelledError)- and (cancelling is None or cancelling() == 0)+ and task is not None+ and task.cancelling() == cancelling_before):raise _request_timeout_exception(request_timeout) from eraisediff --git a/packages/python-sdk/e2b/paginator.py b/packages/python-sdk/e2b/paginator.pyindex a1a2e1130..af507001e 100644--- a/packages/python-sdk/e2b/paginator.py+++ b/packages/python-sdk/e2b/paginator.py@@ -1,6 +1,4 @@-from typing import Generic, Mapping, Optional, TypeVar--from typing_extensions import Unpack+from typing import Generic, Mapping, Optional, TypeVar, Unpackfrom e2b.connection_config import ApiParamsdiff --git a/packages/python-sdk/e2b/sandbox/_git/types.py b/packages/python-sdk/e2b/sandbox/_git/types.pyindex 55f4875b9..739d6042d 100644--- a/packages/python-sdk/e2b/sandbox/_git/types.py+++ b/packages/python-sdk/e2b/sandbox/_git/types.py@@ -1,7 +1,5 @@from dataclasses import dataclass-from typing import List, Optional--from typing_extensions import Literal+from typing import List, Literal, OptionalGitResetMode = Literal["soft", "mixed", "hard", "merge", "keep"]"""Mode for a git reset operation.diff --git a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.pyindex af54390e4..4c0fb0db8 100644--- a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py@@ -240,7 +240,7 @@ class AsyncFileStreamReader(AsyncIterator[bytes]):if self._idle_timeout:return await asyncio.wait_for(read, self._idle_timeout)return await read- except asyncio.TimeoutError as e:+ except TimeoutError as e:# `wait_for`'s expiry; keep the documented httpx exception. The# transport's own idle read timeout already arrives as one.await self.aclose()diff --git a/packages/python-sdk/e2b/sandbox/sandbox_api.py b/packages/python-sdk/e2b/sandbox/sandbox_api.pyindex aaff96288..66199b016 100644--- a/packages/python-sdk/e2b/sandbox/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox/sandbox_api.py@@ -9,14 +9,14 @@ from typing import (List,Literal,Mapping,+ NotRequired,Optional,TypedDict,+ Unpack,Union,cast,)-from typing_extensions import NotRequired, Unpack-from e2b.api.client.models import (ListedSandbox,SandboxDetail,diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.pyindex e59612f92..6835bccf2 100644--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py@@ -255,7 +255,7 @@ class Filesystem:raise await ahandle_envd_api_transport_exception_with_health(e, self._envd_health_api)- except asyncio.TimeoutError as e:+ except TimeoutError as e:# wait_for's expiry; keep the httpx exception the# streamed-read contract established.raise httpx.ReadTimeout(str(e)) from ediff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.pyindex 3d0a648f5..1d3246265 100644--- a/packages/python-sdk/e2b/sandbox_async/main.py+++ b/packages/python-sdk/e2b/sandbox_async/main.py@@ -4,12 +4,10 @@ import jsonimport loggingimport shleximport uuid-from typing import Dict, List, Optional, Union, overload+from typing import Dict, List, Optional, Self, Unpack, Union, overloadimport httpxfrom packaging.version import Version-from typing_extensions import Self, Unpack-from e2b.api.client.types import Unsetfrom e2b.api.client_async import get_envd_apifrom e2b.connection_config import ApiParams, ConnectionConfigdiff --git a/packages/python-sdk/e2b/sandbox_async/paginator.py b/packages/python-sdk/e2b/sandbox_async/paginator.pyindex ee5af6960..42c3b250a 100644--- a/packages/python-sdk/e2b/sandbox_async/paginator.py+++ b/packages/python-sdk/e2b/sandbox_async/paginator.py@@ -1,7 +1,5 @@import urllib.parse-from typing import Optional, List--from typing_extensions import Unpack+from typing import Optional, List, Unpackfrom e2b.api.client.api.sandboxes import get_v2_sandboxesfrom e2b.api.client.api.snapshots import get_snapshotsdiff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.pyindex e41f8ff39..ec30eb6d7 100644--- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py@@ -1,10 +1,8 @@import datetimeimport logging-from typing import Any, Dict, List, Optional, Union, cast+from typing import Any, Dict, List, Optional, Unpack, Union, castfrom packaging.version import Version-from typing_extensions import Unpack-from e2b.api import (SandboxCreateResponse,api_exception_from_code,diff --git a/packages/python-sdk/e2b/sandbox_sync/main.py b/packages/python-sdk/e2b/sandbox_sync/main.pyindex 32c1b671b..4e69efacf 100644--- a/packages/python-sdk/e2b/sandbox_sync/main.py+++ b/packages/python-sdk/e2b/sandbox_sync/main.py@@ -3,12 +3,10 @@ import jsonimport loggingimport shleximport uuid-from typing import Dict, List, Optional, Union, overload+from typing import Dict, List, Optional, Self, Union, Unpack, overloadimport httpxfrom packaging.version import Version-from typing_extensions import Self, Unpack-from e2b.api.client.types import Unsetfrom e2b.api.client_sync import get_envd_apifrom e2b.connection_config import ApiParams, ConnectionConfigdiff --git a/packages/python-sdk/e2b/sandbox_sync/paginator.py b/packages/python-sdk/e2b/sandbox_sync/paginator.pyindex 6538dd6f2..4ccf51c48 100644--- a/packages/python-sdk/e2b/sandbox_sync/paginator.py+++ b/packages/python-sdk/e2b/sandbox_sync/paginator.py@@ -1,7 +1,5 @@import urllib.parse-from typing import Optional, List--from typing_extensions import Unpack+from typing import Optional, List, Unpackfrom e2b.api import handle_api_exceptionfrom e2b.api.client.api.sandboxes import get_v2_sandboxesdiff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.pyindex 8f4db3e89..27e658e39 100644--- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py@@ -1,10 +1,8 @@import datetimeimport logging-from typing import Any, Dict, List, Optional, Union, cast+from typing import Any, Dict, List, Optional, Union, Unpack, castfrom packaging.version import Version-from typing_extensions import Unpack-from e2b.api import (SandboxCreateResponse,api_exception_from_code,diff --git a/packages/python-sdk/e2b/secret/secret_async.py b/packages/python-sdk/e2b/secret/secret_async.pyindex f0e3cdd32..718e0e1e3 100644--- a/packages/python-sdk/e2b/secret/secret_async.py+++ b/packages/python-sdk/e2b/secret/secret_async.py@@ -1,6 +1,4 @@-from typing import Dict, List, Optional--from typing_extensions import Unpack+from typing import Dict, List, Optional, Unpackfrom e2b.api import handle_api_exceptionfrom e2b.api.client.api.secrets import (diff --git a/packages/python-sdk/e2b/secret/secret_sync.py b/packages/python-sdk/e2b/secret/secret_sync.pyindex 908936112..9fc167379 100644--- a/packages/python-sdk/e2b/secret/secret_sync.py+++ b/packages/python-sdk/e2b/secret/secret_sync.py@@ -1,6 +1,4 @@-from typing import Dict, List, Optional--from typing_extensions import Unpack+from typing import Dict, List, Optional, Unpackfrom e2b.api import handle_api_exceptionfrom e2b.api.client.api.secrets import (diff --git a/packages/python-sdk/e2b/template/types.py b/packages/python-sdk/e2b/template/types.pyindex ca2c79c73..a8458fe19 100644--- a/packages/python-sdk/e2b/template/types.py+++ b/packages/python-sdk/e2b/template/types.py@@ -2,9 +2,7 @@ from dataclasses import dataclass, fieldfrom datetime import datetimefrom enum import Enumfrom pathlib import Path-from typing import List, Literal, Optional, TypedDict, Union--from typing_extensions import NotRequired+from typing import List, Literal, NotRequired, Optional, TypedDict, Unionfrom e2b.template.logger import LogEntrydiff --git a/packages/python-sdk/e2b/template_async/main.py b/packages/python-sdk/e2b/template_async/main.pyindex 3672748a3..a8ef1104e 100644--- a/packages/python-sdk/e2b/template_async/main.py+++ b/packages/python-sdk/e2b/template_async/main.py@@ -1,7 +1,5 @@from datetime import datetime-from typing import Callable, List, Optional, Union--from typing_extensions import Unpack+from typing import Callable, List, Optional, Union, Unpackfrom e2b.api.client.client import AuthenticatedClientfrom e2b.api.client.types import Unsetdiff --git a/packages/python-sdk/e2b/template_sync/main.py b/packages/python-sdk/e2b/template_sync/main.pyindex f42bb5c3b..98e62284d 100644--- a/packages/python-sdk/e2b/template_sync/main.py+++ b/packages/python-sdk/e2b/template_sync/main.py@@ -1,7 +1,5 @@from datetime import datetime-from typing import Callable, List, Optional, Union--from typing_extensions import Unpack+from typing import Callable, List, Optional, Union, Unpackfrom e2b.api.client.client import AuthenticatedClientfrom e2b.api.client.types import Unsetdiff --git a/packages/python-sdk/e2b/volume/connection_config.py b/packages/python-sdk/e2b/volume/connection_config.pyindex e636a208d..069dffb13 100644--- a/packages/python-sdk/e2b/volume/connection_config.py+++ b/packages/python-sdk/e2b/volume/connection_config.py@@ -1,9 +1,7 @@import loggingimport os-from typing import Dict, Optional, TypedDict--from typing_extensions import Unpack+from typing import Dict, Optional, TypedDict, Unpackfrom e2b.api.metadata import package_versionfrom e2b.connection_config import HttpVersion, ProxyTypes, resolve_http_versiondiff --git a/packages/python-sdk/e2b/volume/volume_async.py b/packages/python-sdk/e2b/volume/volume_async.pyindex ec7034a85..5a7a22b73 100644--- a/packages/python-sdk/e2b/volume/volume_async.py+++ b/packages/python-sdk/e2b/volume/volume_async.py@@ -1,12 +1,21 @@import asyncio-from typing import AsyncIterator, IO, List, Literal, Optional, Union, cast, overload+from typing import (+ AsyncIterator,+ IO,+ List,+ Literal,+ Optional,+ Self,+ Union,+ Unpack,+ cast,+ overload,+)from http import HTTPStatusimport httpx-from typing_extensions import Self, Unpack-from e2b.api import handle_api_exceptionfrom e2b.api.client.api.volumes import (post_volumes,@@ -583,7 +592,7 @@ class AsyncVolume(ClientFactory):yield chunkfinally:await stream_cm.__aexit__(None, None, None)- except asyncio.TimeoutError as e:+ except TimeoutError as e:raise httpx.ReadTimeout(str(e)) from ereturn stream_file()diff --git a/packages/python-sdk/e2b/volume/volume_sync.py b/packages/python-sdk/e2b/volume/volume_sync.pyindex 187fe6aed..45b95c654 100644--- a/packages/python-sdk/e2b/volume/volume_sync.py+++ b/packages/python-sdk/e2b/volume/volume_sync.py@@ -1,11 +1,20 @@import io-from typing import IO, Iterator, List, Literal, Optional, Union, cast, overload+from typing import (+ IO,+ Iterator,+ List,+ Literal,+ Optional,+ Self,+ Union,+ Unpack,+ cast,+ overload,+)from http import HTTPStatusimport httpx-from typing_extensions import Self, Unpack-from e2b.api import handle_api_exceptionfrom e2b.api.client.api.volumes import (post_volumes,diff --git a/packages/python-sdk/tests/test_envd_stream_request_timeout.py b/packages/python-sdk/tests/test_envd_stream_request_timeout.pyindex 82c829ef7..64ddc9f32 100644--- a/packages/python-sdk/tests/test_envd_stream_request_timeout.py+++ b/packages/python-sdk/tests/test_envd_stream_request_timeout.py@@ -55,6 +55,21 @@ async def test_timeout_raises_timeout_exception():assert time.monotonic() - start < 5+async def test_timeout_with_preexisting_pending_cancellation():+ task = asyncio.current_task()+ assert task is not None+ task.cancel()+ try:+ await asyncio.sleep(0)+ except asyncio.CancelledError:+ pass++ start = time.monotonic()+ with pytest.raises(TimeoutException, match="request_timeout"):+ await first_event(connectrpc_style_stream(30), 0.1)+ assert time.monotonic() - start < 5++async def test_timeout_when_cancellation_propagates():# A stream cancelled outside connectrpc's conversion scope (e.g. before# the request is sent) lets wait_for raise TimeoutError itself.