Skip to content

Commit b0a2e7d

Browse files
committed
Change ApiParams to TypedDict to support typing correctly
1 parent 7570417 commit b0a2e7d

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

packages/python-sdk/e2b/connection_config.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22

3-
from typing import Literal, Optional, Dict
4-
from dataclasses import dataclass
3+
from typing import Literal, Optional, Dict, TypedDict
54
from httpx._types import ProxyTypes
65
from typing_extensions import Unpack
76

@@ -13,8 +12,7 @@
1312
KEEPALIVE_PING_HEADER = "Keepalive-Ping-Interval"
1413

1514

16-
@dataclass
17-
class ApiParams:
15+
class ApiParams(TypedDict):
1816
"""
1917
Parameters for a request.
2018
@@ -23,19 +21,19 @@ class ApiParams:
2321

2422
request_timeout: Optional[float]
2523
"""Timeout for the request in **seconds**, defaults to 60 seconds."""
26-
24+
2725
headers: Dict[str, str]
2826
"""Additional headers to send with the request."""
29-
27+
3028
api_key: Optional[str]
3129
"""E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable."""
32-
33-
domain: str
30+
31+
domain: Optional[str]
3432
"""E2B domain to use for authentication, defaults to `E2B_DOMAIN` environment variable."""
35-
36-
debug: bool
33+
34+
debug: Optional[bool]
3735
"""Whether to use debug mode, defaults to `E2B_DEBUG` environment variable."""
38-
36+
3937
proxy: Optional[ProxyTypes]
4038
"""Proxy to use for the request. In case of a sandbox it applies to all **requests made to the returned sandbox**."""
4139

@@ -139,14 +137,16 @@ def get_api_params(
139137
if headers is not None:
140138
req_headers.update(headers)
141139

142-
return ApiParams(
143-
api_key=api_key if api_key is not None else self.api_key,
144-
domain=domain if domain is not None else self.domain,
145-
debug=debug if debug is not None else self.debug,
146-
request_timeout=self.get_request_timeout(request_timeout),
147-
headers=req_headers,
148-
proxy=proxy if proxy is not None else self.proxy,
149-
).__dict__
140+
return dict(
141+
ApiParams(
142+
api_key=api_key if api_key is not None else self.api_key,
143+
domain=domain if domain is not None else self.domain,
144+
debug=debug if debug is not None else self.debug,
145+
request_timeout=self.get_request_timeout(request_timeout),
146+
headers=req_headers,
147+
proxy=proxy if proxy is not None else self.proxy,
148+
)
149+
)
150150

151151
@property
152152
def sandbox_headers(self):

0 commit comments

Comments
 (0)