From e1e7a5f1446784c576da0336ee166b778017dd05 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:23:51 +0200 Subject: [PATCH 01/10] Add language autocomplete for js, ts, r, java, bash Co-Authored-By: Claude Opus 4.6 --- .changeset/add-language-overloads.md | 6 +++ js/src/sandbox.ts | 27 +------------ .../code_interpreter_async.py | 38 +------------------ .../code_interpreter_sync.py | 38 +------------------ 4 files changed, 12 insertions(+), 97 deletions(-) create mode 100644 .changeset/add-language-overloads.md diff --git a/.changeset/add-language-overloads.md b/.changeset/add-language-overloads.md new file mode 100644 index 00000000..0a1f00bd --- /dev/null +++ b/.changeset/add-language-overloads.md @@ -0,0 +1,6 @@ +--- +"@e2b/code-interpreter": patch +"e2b-code-interpreter": patch +--- + +Add autocomplete support for javascript, typescript, r, java, and bash languages in runCode/run_code and createCodeContext/create_code_context diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index a02b9d9e..59a716a4 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -88,7 +88,7 @@ export interface CreateCodeContextOpts { * * @default python */ - language?: string + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) /** * Timeout for the request in **milliseconds**. * @@ -128,29 +128,6 @@ export class Sandbox extends BaseSandbox { )}` } - /** - * Run the code as Python. - * - * Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - * - * You can reference previously defined variables, imports, and functions in the code. - * - * @param code code to execute. - * @param opts options for executing the code. - * - * @returns `Execution` result object. - */ - async runCode( - code: string, - opts?: RunCodeOpts & { - /** - * Language to use for code execution. - * - * If not defined, the default Python context is used. - */ - language?: 'python' - } - ): Promise /** * Run the code for the specified language. * @@ -172,7 +149,7 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - language?: string + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) } ): Promise /** diff --git a/python/e2b_code_interpreter/code_interpreter_async.py b/python/e2b_code_interpreter/code_interpreter_async.py index de938240..e9788bc8 100644 --- a/python/e2b_code_interpreter/code_interpreter_async.py +++ b/python/e2b_code_interpreter/code_interpreter_async.py @@ -68,41 +68,7 @@ def _client(self) -> AsyncClient: async def run_code( self, code: str, - language: Union[Literal["python"], None] = None, - on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None, - on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None, - on_result: Optional[OutputHandlerWithAsync[Result]] = None, - on_error: Optional[OutputHandlerWithAsync[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None, - ) -> Execution: - """ - Runs the code as Python. - - Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - - You can reference previously defined variables, imports, and functions in the code. - - :param code: Code to execute - :param language: Language to use for code execution. If not defined, the default Python context is used. - :param on_stdout: Callback for stdout messages - :param on_stderr: Callback for stderr messages - :param on_result: Callback for the `Result` object - :param on_error: Callback for the `ExecutionError` object - :param envs: Custom environment variables - :param timeout: Timeout for the code execution in **seconds** - :param request_timeout: Timeout for the request in **seconds** - - :return: `Execution` result object - """ - ... - - @overload - async def run_code( - self, - code: str, - language: Optional[str] = None, + language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_result: Optional[OutputHandlerWithAsync[Result]] = None, @@ -236,7 +202,7 @@ async def run_code( async def create_code_context( self, cwd: Optional[str] = None, - language: Optional[str] = None, + language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/code_interpreter_sync.py b/python/e2b_code_interpreter/code_interpreter_sync.py index 3adb2804..5e3e4422 100644 --- a/python/e2b_code_interpreter/code_interpreter_sync.py +++ b/python/e2b_code_interpreter/code_interpreter_sync.py @@ -65,41 +65,7 @@ def _client(self) -> Client: def run_code( self, code: str, - language: Union[Literal["python"], None] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None, - ) -> Execution: - """ - Runs the code as Python. - - Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - - You can reference previously defined variables, imports, and functions in the code. - - :param code: Code to execute - :param language: Language to use for code execution. If not defined, the default Python context is used. - :param on_stdout: Callback for stdout messages - :param on_stderr: Callback for stderr messages - :param on_result: Callback for the `Result` object - :param on_error: Callback for the `ExecutionError` object - :param envs: Custom environment variables - :param timeout: Timeout for the code execution in **seconds** - :param request_timeout: Timeout for the request in **seconds** - - :return: `Execution` result object - """ - ... - - @overload - def run_code( - self, - code: str, - language: Optional[str] = None, + language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, on_stdout: Optional[OutputHandler[OutputMessage]] = None, on_stderr: Optional[OutputHandler[OutputMessage]] = None, on_result: Optional[OutputHandler[Result]] = None, @@ -232,7 +198,7 @@ def run_code( def create_code_context( self, cwd: Optional[str] = None, - language: Optional[str] = None, + language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, request_timeout: Optional[float] = None, ) -> Context: """ From 935ecb7f23a7efd19819f46b208d59e2399d0695 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:29:35 +0200 Subject: [PATCH 02/10] Fix eslint ban-types error for string & {} Use NonNullable instead of {} to satisfy @typescript-eslint/ban-types. Co-Authored-By: Claude Opus 4.6 --- js/src/sandbox.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index 59a716a4..26025ce5 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -88,7 +88,7 @@ export interface CreateCodeContextOpts { * * @default python */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & NonNullable) /** * Timeout for the request in **milliseconds**. * @@ -149,7 +149,7 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & NonNullable) } ): Promise /** From 46a7fcc54062e9ff816d9ecd8a03b42a861a7bbc Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:30:33 +0200 Subject: [PATCH 03/10] Simplify language type to plain string union Co-Authored-By: Claude Opus 4.6 --- js/src/sandbox.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index 26025ce5..761701e7 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -88,7 +88,7 @@ export interface CreateCodeContextOpts { * * @default python */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & NonNullable) + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | string /** * Timeout for the request in **milliseconds**. * @@ -149,7 +149,7 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & NonNullable) + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | string } ): Promise /** From 81780fed885825194b1945ca09569eb09b31e0a7 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:31:48 +0200 Subject: [PATCH 04/10] Use string & {} with eslint-disable for language autocomplete Co-Authored-By: Claude Opus 4.6 --- js/src/sandbox.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index 761701e7..cbd5c78a 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -88,7 +88,8 @@ export interface CreateCodeContextOpts { * * @default python */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | string + // eslint-disable-next-line @typescript-eslint/ban-types + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) /** * Timeout for the request in **milliseconds**. * @@ -149,7 +150,8 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | string + // eslint-disable-next-line @typescript-eslint/ban-types + language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) } ): Promise /** From 53fdd42992deb4027de56547cda6c3c9c0c21053 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:34:07 +0200 Subject: [PATCH 05/10] Format sandbox.ts with prettier Co-Authored-By: Claude Opus 4.6 --- js/src/sandbox.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index cbd5c78a..7738e09b 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -89,7 +89,14 @@ export interface CreateCodeContextOpts { * @default python */ // eslint-disable-next-line @typescript-eslint/ban-types - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) + language?: + | 'python' + | 'javascript' + | 'typescript' + | 'r' + | 'java' + | 'bash' + | (string & {}) /** * Timeout for the request in **milliseconds**. * @@ -151,7 +158,14 @@ export class Sandbox extends BaseSandbox { * If not defined, the default Python context is used. */ // eslint-disable-next-line @typescript-eslint/ban-types - language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {}) + language?: + | 'python' + | 'javascript' + | 'typescript' + | 'r' + | 'java' + | 'bash' + | (string & {}) } ): Promise /** From 97f712f31cef15c49aa872cee9daae044548f761 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:36:26 +0200 Subject: [PATCH 06/10] Use eslint-disable/enable block for ban-types on multiline type Co-Authored-By: Claude Opus 4.6 --- js/src/sandbox.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index 7738e09b..5d12b93a 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -88,7 +88,7 @@ export interface CreateCodeContextOpts { * * @default python */ - // eslint-disable-next-line @typescript-eslint/ban-types + /* eslint-disable @typescript-eslint/ban-types */ language?: | 'python' | 'javascript' @@ -97,6 +97,7 @@ export interface CreateCodeContextOpts { | 'java' | 'bash' | (string & {}) + /* eslint-enable @typescript-eslint/ban-types */ /** * Timeout for the request in **milliseconds**. * @@ -157,7 +158,7 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - // eslint-disable-next-line @typescript-eslint/ban-types + /* eslint-disable @typescript-eslint/ban-types */ language?: | 'python' | 'javascript' @@ -166,6 +167,7 @@ export class Sandbox extends BaseSandbox { | 'java' | 'bash' | (string & {}) + /* eslint-enable @typescript-eslint/ban-types */ } ): Promise /** From bf3e25b13b3bb49a0e28b6752eabb83b70da5c5d Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:38:55 +0200 Subject: [PATCH 07/10] Format Python language type annotations for ruff Co-Authored-By: Claude Opus 4.6 --- .../e2b_code_interpreter/code_interpreter_async.py | 12 ++++++++++-- python/e2b_code_interpreter/code_interpreter_sync.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/python/e2b_code_interpreter/code_interpreter_async.py b/python/e2b_code_interpreter/code_interpreter_async.py index e9788bc8..68001c19 100644 --- a/python/e2b_code_interpreter/code_interpreter_async.py +++ b/python/e2b_code_interpreter/code_interpreter_async.py @@ -68,7 +68,11 @@ def _client(self) -> AsyncClient: async def run_code( self, code: str, - language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, + language: Union[ + Literal["python", "javascript", "typescript", "r", "java", "bash"], + str, + None, + ] = None, on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_result: Optional[OutputHandlerWithAsync[Result]] = None, @@ -202,7 +206,11 @@ async def run_code( async def create_code_context( self, cwd: Optional[str] = None, - language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, + language: Union[ + Literal["python", "javascript", "typescript", "r", "java", "bash"], + str, + None, + ] = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/code_interpreter_sync.py b/python/e2b_code_interpreter/code_interpreter_sync.py index 5e3e4422..8e6eb743 100644 --- a/python/e2b_code_interpreter/code_interpreter_sync.py +++ b/python/e2b_code_interpreter/code_interpreter_sync.py @@ -65,7 +65,11 @@ def _client(self) -> Client: def run_code( self, code: str, - language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, + language: Union[ + Literal["python", "javascript", "typescript", "r", "java", "bash"], + str, + None, + ] = None, on_stdout: Optional[OutputHandler[OutputMessage]] = None, on_stderr: Optional[OutputHandler[OutputMessage]] = None, on_result: Optional[OutputHandler[Result]] = None, @@ -198,7 +202,11 @@ def run_code( def create_code_context( self, cwd: Optional[str] = None, - language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None, + language: Union[ + Literal["python", "javascript", "typescript", "r", "java", "bash"], + str, + None, + ] = None, request_timeout: Optional[float] = None, ) -> Context: """ From de318896b9bb1c4df2097de3be87a05ef489145b Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 16 Apr 2026 17:30:16 +0200 Subject: [PATCH 08/10] Extract RunCodeLanguage type to deduplicate language unions Co-Authored-By: Claude Opus 4.6 --- js/src/index.ts | 2 +- js/src/sandbox.ts | 36 +++++++++---------- python/e2b_code_interpreter/__init__.py | 1 + .../code_interpreter_async.py | 15 +++----- .../code_interpreter_sync.py | 15 +++----- python/e2b_code_interpreter/models.py | 7 ++++ 6 files changed, 33 insertions(+), 43 deletions(-) diff --git a/js/src/index.ts b/js/src/index.ts index 2ad762ba..1d337f78 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -1,7 +1,7 @@ export * from 'e2b' export { Sandbox } from './sandbox' -export type { Context, RunCodeOpts, CreateCodeContextOpts } from './sandbox' +export type { Context, RunCodeLanguage, RunCodeOpts, CreateCodeContextOpts } from './sandbox' export type { Logs, ExecutionError, diff --git a/js/src/sandbox.ts b/js/src/sandbox.ts index 5d12b93a..0b320cc6 100644 --- a/js/src/sandbox.ts +++ b/js/src/sandbox.ts @@ -33,6 +33,20 @@ export type Context = { cwd: string } +/* eslint-disable @typescript-eslint/ban-types */ +/** + * Supported language for code execution. + */ +export type RunCodeLanguage = + | 'python' + | 'javascript' + | 'typescript' + | 'r' + | 'java' + | 'bash' + | (string & {}) +/* eslint-enable @typescript-eslint/ban-types */ + /** * Options for running code. */ @@ -88,16 +102,7 @@ export interface CreateCodeContextOpts { * * @default python */ - /* eslint-disable @typescript-eslint/ban-types */ - language?: - | 'python' - | 'javascript' - | 'typescript' - | 'r' - | 'java' - | 'bash' - | (string & {}) - /* eslint-enable @typescript-eslint/ban-types */ + language?: RunCodeLanguage /** * Timeout for the request in **milliseconds**. * @@ -158,16 +163,7 @@ export class Sandbox extends BaseSandbox { * * If not defined, the default Python context is used. */ - /* eslint-disable @typescript-eslint/ban-types */ - language?: - | 'python' - | 'javascript' - | 'typescript' - | 'r' - | 'java' - | 'bash' - | (string & {}) - /* eslint-enable @typescript-eslint/ban-types */ + language?: RunCodeLanguage } ): Promise /** diff --git a/python/e2b_code_interpreter/__init__.py b/python/e2b_code_interpreter/__init__.py index 7562f51a..5202d5de 100644 --- a/python/e2b_code_interpreter/__init__.py +++ b/python/e2b_code_interpreter/__init__.py @@ -10,4 +10,5 @@ Logs, OutputHandler, OutputMessage, + RunCodeLanguage, ) diff --git a/python/e2b_code_interpreter/code_interpreter_async.py b/python/e2b_code_interpreter/code_interpreter_async.py index 68001c19..856c15ab 100644 --- a/python/e2b_code_interpreter/code_interpreter_async.py +++ b/python/e2b_code_interpreter/code_interpreter_async.py @@ -1,7 +1,7 @@ import logging import httpx -from typing import Optional, Dict, overload, Union, Literal, List +from typing import Optional, Dict, overload, Union, List from httpx import AsyncClient from e2b import ( @@ -18,6 +18,7 @@ Execution, ExecutionError, Context, + RunCodeLanguage, Result, aextract_exception, OutputHandlerWithAsync, @@ -68,11 +69,7 @@ def _client(self) -> AsyncClient: async def run_code( self, code: str, - language: Union[ - Literal["python", "javascript", "typescript", "r", "java", "bash"], - str, - None, - ] = None, + language: RunCodeLanguage = None, on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_result: Optional[OutputHandlerWithAsync[Result]] = None, @@ -206,11 +203,7 @@ async def run_code( async def create_code_context( self, cwd: Optional[str] = None, - language: Union[ - Literal["python", "javascript", "typescript", "r", "java", "bash"], - str, - None, - ] = None, + language: RunCodeLanguage = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/code_interpreter_sync.py b/python/e2b_code_interpreter/code_interpreter_sync.py index 8e6eb743..ae5de50d 100644 --- a/python/e2b_code_interpreter/code_interpreter_sync.py +++ b/python/e2b_code_interpreter/code_interpreter_sync.py @@ -1,7 +1,7 @@ import logging import httpx -from typing import Optional, Dict, overload, Literal, Union, List +from typing import Optional, Dict, overload, Union, List from httpx import Client from e2b import Sandbox as BaseSandbox, InvalidArgumentException @@ -13,6 +13,7 @@ from e2b_code_interpreter.models import ( ExecutionError, Execution, + RunCodeLanguage, Context, Result, extract_exception, @@ -65,11 +66,7 @@ def _client(self) -> Client: def run_code( self, code: str, - language: Union[ - Literal["python", "javascript", "typescript", "r", "java", "bash"], - str, - None, - ] = None, + language: RunCodeLanguage = None, on_stdout: Optional[OutputHandler[OutputMessage]] = None, on_stderr: Optional[OutputHandler[OutputMessage]] = None, on_result: Optional[OutputHandler[Result]] = None, @@ -202,11 +199,7 @@ def run_code( def create_code_context( self, cwd: Optional[str] = None, - language: Union[ - Literal["python", "javascript", "typescript", "r", "java", "bash"], - str, - None, - ] = None, + language: RunCodeLanguage = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/models.py b/python/e2b_code_interpreter/models.py index ef280e18..7e6429cf 100644 --- a/python/e2b_code_interpreter/models.py +++ b/python/e2b_code_interpreter/models.py @@ -6,6 +6,7 @@ from dataclasses import dataclass, field from typing import ( List, + Literal, Optional, Iterable, Dict, @@ -20,6 +21,12 @@ from .charts import Chart, _deserialize_chart +RunCodeLanguage = Union[ + Literal["python", "javascript", "typescript", "r", "java", "bash"], + str, + None, +] + T = TypeVar("T") OutputHandler = Union[Callable[[T], Any],] From 1f7997e9d4823da9296fb272d54e2159c72bdd62 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:21:03 +0200 Subject: [PATCH 09/10] Remove None from RunCodeLanguage, use Optional in signatures Co-Authored-By: Claude Opus 4.6 --- python/e2b_code_interpreter/code_interpreter_async.py | 4 ++-- python/e2b_code_interpreter/code_interpreter_sync.py | 4 ++-- python/e2b_code_interpreter/models.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/python/e2b_code_interpreter/code_interpreter_async.py b/python/e2b_code_interpreter/code_interpreter_async.py index 856c15ab..35684cd1 100644 --- a/python/e2b_code_interpreter/code_interpreter_async.py +++ b/python/e2b_code_interpreter/code_interpreter_async.py @@ -69,7 +69,7 @@ def _client(self) -> AsyncClient: async def run_code( self, code: str, - language: RunCodeLanguage = None, + language: Optional[RunCodeLanguage] = None, on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None, on_result: Optional[OutputHandlerWithAsync[Result]] = None, @@ -203,7 +203,7 @@ async def run_code( async def create_code_context( self, cwd: Optional[str] = None, - language: RunCodeLanguage = None, + language: Optional[RunCodeLanguage] = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/code_interpreter_sync.py b/python/e2b_code_interpreter/code_interpreter_sync.py index ae5de50d..6020cc89 100644 --- a/python/e2b_code_interpreter/code_interpreter_sync.py +++ b/python/e2b_code_interpreter/code_interpreter_sync.py @@ -66,7 +66,7 @@ def _client(self) -> Client: def run_code( self, code: str, - language: RunCodeLanguage = None, + language: Optional[RunCodeLanguage] = None, on_stdout: Optional[OutputHandler[OutputMessage]] = None, on_stderr: Optional[OutputHandler[OutputMessage]] = None, on_result: Optional[OutputHandler[Result]] = None, @@ -199,7 +199,7 @@ def run_code( def create_code_context( self, cwd: Optional[str] = None, - language: RunCodeLanguage = None, + language: Optional[RunCodeLanguage] = None, request_timeout: Optional[float] = None, ) -> Context: """ diff --git a/python/e2b_code_interpreter/models.py b/python/e2b_code_interpreter/models.py index 7e6429cf..ff691b54 100644 --- a/python/e2b_code_interpreter/models.py +++ b/python/e2b_code_interpreter/models.py @@ -24,7 +24,6 @@ RunCodeLanguage = Union[ Literal["python", "javascript", "typescript", "r", "java", "bash"], str, - None, ] T = TypeVar("T") From 7c678b86b8db27f42e8cf3aa6464ceaea9458685 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:37:22 +0200 Subject: [PATCH 10/10] Format index.ts exports Co-Authored-By: Claude Opus 4.6 --- js/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/src/index.ts b/js/src/index.ts index 1d337f78..d4598121 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -1,7 +1,12 @@ export * from 'e2b' export { Sandbox } from './sandbox' -export type { Context, RunCodeLanguage, RunCodeOpts, CreateCodeContextOpts } from './sandbox' +export type { + Context, + RunCodeLanguage, + RunCodeOpts, + CreateCodeContextOpts, +} from './sandbox' export type { Logs, ExecutionError,