Skip to content

Commit 438e5da

Browse files
feat: support Python 3.10 (#25)
1 parent 6adb142 commit 438e5da

File tree

10 files changed

+173
-22
lines changed

10 files changed

+173
-22
lines changed

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.14
1+
3.10

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.5.0"
44
description = "Deno Sandbox Python SDK"
55
readme = "README.md"
66
authors = [{ name = "The Deno Team", email = "support@deno.com" }]
7-
requires-python = ">=3.14"
7+
requires-python = ">=3.10"
88
dependencies = [
99
"httpx>=0.28.1",
1010
"typing-extensions>=4.15.0",

src/deno_sandbox/api_types_generated.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ATTENTION: This file is auto-generated. Do not edit it manually.
22

3+
from __future__ import annotations
34

45
from typing_extensions import TypedDict, NotRequired, Literal
56
from re import Pattern

src/deno_sandbox/console.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import annotations
2+
13
from datetime import datetime, timezone
2-
from typing import Any, Literal, Optional, TypedDict, cast
4+
from typing import Any, Generic, Literal, Optional, TypedDict, TypeVar, cast
35
import httpx
46

57
from .api_types_generated import (
@@ -24,6 +26,9 @@
2426
from .options import InternalOptions
2527
from .utils import convert_to_snake_case, parse_link_header
2628

29+
T = TypeVar("T")
30+
O = TypeVar("O") # noqa: E741
31+
2732

2833
class Revision(RevisionWithoutTimelines):
2934
timelines: list[Timeline]
@@ -40,7 +45,7 @@ class ExposeHTTPResult(TypedDict):
4045
domain: str
4146

4247

43-
class AsyncPaginatedList[T, O]:
48+
class AsyncPaginatedList(Generic[T, O]):
4449
def __init__(
4550
self,
4651
client: AsyncConsoleClient,
@@ -88,7 +93,7 @@ async def __anext__(self):
8893
return next_page
8994

9095

91-
class PaginatedList[T, O]:
96+
class PaginatedList(Generic[T, O]):
9297
def __init__(
9398
self,
9499
bridge: AsyncBridge,
@@ -187,7 +192,7 @@ async def delete(self, path: str) -> httpx.Response:
187192
response = await self._request("DELETE", req_url)
188193
return response
189194

190-
async def get_paginated[T, O](
195+
async def get_paginated(
191196
self,
192197
path: str,
193198
cursor: Optional[str],
@@ -379,7 +384,7 @@ def __init__(self, options: InternalOptions, bridge: AsyncBridge):
379384
self._async = AsyncConsoleClient(options)
380385
self._bridge = bridge
381386

382-
def get_paginated[T, O](
387+
def get_paginated(
383388
self, path: str, cursor: Optional[str], params: Optional[O] = None
384389
) -> PaginatedList[T, O]:
385390
async_paginated = self._bridge.run(

src/deno_sandbox/options.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from __future__ import annotations
2+
13
import os
24

3-
from typing import NotRequired, Optional, TypedDict
5+
from typing import Optional, TypedDict
6+
from typing_extensions import NotRequired
47

58
from httpx import URL
69

src/deno_sandbox/rpc.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import annotations
2+
13
import asyncio
24
import base64
35
import json
4-
from typing import Any, Dict, Literal, Mapping, NotRequired, Optional, TypedDict, cast
6+
from typing import Any, Dict, Literal, Mapping, Optional, TypedDict, cast
7+
from typing_extensions import NotRequired
58
from websockets import ConnectionClosed
69

710
from .bridge import AsyncBridge
@@ -27,15 +30,15 @@ class RpcRequest(TypedDict):
2730
jsonrpc: str
2831

2932

30-
class RpcResult[T](TypedDict):
31-
ok: NotRequired[T | None]
32-
error: NotRequired[Any | None]
33+
class RpcResult(TypedDict):
34+
ok: NotRequired[Any]
35+
error: NotRequired[Any]
3336

3437

35-
class RpcResponse[T](TypedDict):
38+
class RpcResponse(TypedDict):
3639
id: int
3740
jsonrpc: str
38-
result: NotRequired[RpcResult[T] | None]
41+
result: NotRequired[RpcResult | None]
3942
error: NotRequired[dict[str, Any] | None]
4043

4144

@@ -76,7 +79,7 @@ async def call(self, method: str, params: Mapping[str, Any]) -> Any:
7679
await self._transport.send(json.dumps(payload))
7780

7881
raw_response = await future
79-
response = cast(RpcResponse[Any], raw_response)
82+
response = cast(RpcResponse, raw_response)
8083

8184
maybeError = response.get("error")
8285
if maybeError is not None:

src/deno_sandbox/sandbox.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
from __future__ import annotations
2+
13
import base64
24
from contextlib import asynccontextmanager, contextmanager
35
from datetime import datetime, timedelta, timezone
46
import json
57
from typing import (
68
Any,
79
AsyncIterator,
8-
NotRequired,
910
Optional,
1011
TypedDict,
1112
cast,
1213
)
13-
from typing_extensions import Literal
14+
from typing_extensions import Literal, NotRequired, TypeAlias
1415

1516
from .api_generated import (
1617
AsyncSandboxEnv,
@@ -63,8 +64,8 @@
6364
)
6465

6566

66-
type Mode = Literal["connect", "create"]
67-
type StdIo = Literal["piped", "null"]
67+
Mode: TypeAlias = Literal["connect", "create"]
68+
StdIo: TypeAlias = Literal["piped", "null"]
6869

6970

7071
class SecretConfig(TypedDict):

src/deno_sandbox/transport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from websockets import ClientConnection, ConnectionClosed, connect
24
from httpx import URL
35

src/deno_sandbox/wrappers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from __future__ import annotations
2+
13
import asyncio
24
import base64
35
import sys
4-
from typing import Any, BinaryIO, Callable, Optional, TypedDict, cast
6+
from typing import Any, BinaryIO, Callable, Optional, TypedDict, TypeVar, cast
57
from typing_extensions import Literal
8+
69
from .bridge import AsyncBridge
710
from .errors import ProcessAlreadyExited
811
from .rpc import (
@@ -12,6 +15,8 @@
1215
RpcClient,
1316
)
1417

18+
T = TypeVar("T")
19+
1520

1621
class FileInfo(TypedDict):
1722
is_file: bool
@@ -303,7 +308,7 @@ async def _pipe_stream(reader: asyncio.StreamReader, writer: BinaryIO):
303308
pass
304309

305310

306-
def create_process_like[T](
311+
def create_process_like(
307312
cls: Callable[
308313
[
309314
int,

0 commit comments

Comments
 (0)