Skip to content

Commit 4cc714a

Browse files
chore: remove unused code + inline generated types (#32)
1 parent 08f8ec7 commit 4cc714a

File tree

11 files changed

+281
-818
lines changed

11 files changed

+281
-818
lines changed

src/deno_sandbox/api_types_generated.py

Lines changed: 0 additions & 774 deletions
This file was deleted.

src/deno_sandbox/apps.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from __future__ import annotations
22

3-
from typing import Any, cast
3+
from typing import Any, TypedDict, cast
44
from typing_extensions import Optional
55

6-
from .api_types_generated import (
7-
App,
8-
)
96
from .utils import convert_to_snake_case
107
from .bridge import AsyncBridge
118
from .console import (
@@ -15,6 +12,20 @@
1512
)
1613

1714

15+
class App(TypedDict):
16+
id: str
17+
"""The unique identifier for the app."""
18+
19+
slug: str
20+
"""The human readable identifier for the app."""
21+
22+
created_at: str
23+
"""The ISO 8601 timestamp when the app was created."""
24+
25+
updated_at: str
26+
"""The ISO 8601 timestamp when the app was last updated."""
27+
28+
1829
class AsyncApps:
1930
def __init__(self, client: AsyncConsoleClient):
2031
self._client = client

src/deno_sandbox/console.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,13 @@
1212
)
1313
import httpx
1414

15-
from .api_types_generated import (
16-
RevisionWithoutTimelines,
17-
Timeline,
18-
)
1915
from .bridge import AsyncBridge
2016
from .options import InternalOptions
2117
from .utils import convert_to_snake_case, parse_link_header
2218

2319
T = TypeVar("T")
2420

2521

26-
class Revision(RevisionWithoutTimelines):
27-
timelines: list[Timeline]
28-
"""The timelines associated with the revision."""
29-
30-
3122
class ExposeSSHResult(TypedDict):
3223
hostname: str
3324
username: str

src/deno_sandbox/fs.py

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@
1010
Iterable,
1111
Literal,
1212
Optional,
13+
TypedDict,
1314
Union,
1415
cast,
1516
)
1617

1718
from re import Pattern
1819

19-
from .api_types_generated import (
20-
DirEntry,
21-
FileInfo,
22-
FsFileHandle,
23-
WalkEntry,
24-
)
2520
from .process import AbortSignal
2621
from .stream import stream_data
2722
from .utils import convert_to_camel_case, convert_to_snake_case
@@ -31,6 +26,106 @@
3126
from .bridge import AsyncBridge
3227

3328

29+
class DirEntry(TypedDict):
30+
name: str
31+
"""The file or directory name."""
32+
33+
is_file: bool
34+
"""Whether the entry is a file."""
35+
36+
is_directory: bool
37+
"""Whether the entry is a directory."""
38+
39+
is_symlink: bool
40+
"""Whether the entry is a symbolic link."""
41+
42+
43+
class FileInfo(TypedDict):
44+
is_file: bool
45+
"""Whether the path is a file."""
46+
47+
is_directory: bool
48+
"""Whether the path is a directory."""
49+
50+
is_symlink: bool
51+
"""Whether the path is a symbolic link."""
52+
53+
size: int
54+
"""The size of the file in bytes."""
55+
56+
mtime: str
57+
"""The last modification time of the file."""
58+
59+
atime: str
60+
"""The last access time of the file."""
61+
62+
birthtime: str
63+
"""The creation time of the file."""
64+
65+
ctime: str
66+
"""The last status change time of the file."""
67+
68+
dev: int
69+
"""The device ID."""
70+
71+
ino: int
72+
"""The inode number."""
73+
74+
mode: int
75+
"""The file mode."""
76+
77+
nlink: int
78+
"""The number of hard links pointing to this file."""
79+
80+
uid: int
81+
"""The user ID of the owner."""
82+
83+
gid: int
84+
"""The group ID of the owner."""
85+
86+
rdev: int
87+
"""The device ID of this file."""
88+
89+
blksize: int
90+
"""The block size for filesystem I/O."""
91+
92+
blocks: int
93+
"""The number of blocks allocated in 512-byte units"""
94+
95+
is_block_device: bool
96+
"""Whether the path is a block device."""
97+
98+
is_char_device: bool
99+
"""Whether the path is a character device."""
100+
101+
is_fifo: bool
102+
"""Whether the path is a FIFO."""
103+
104+
is_socket: bool
105+
"""Whether the path is a socket."""
106+
107+
108+
class WalkEntry(TypedDict):
109+
path: str
110+
"""The full path of the entry."""
111+
112+
name: str
113+
"""The file or directory name."""
114+
115+
is_file: bool
116+
"""Whether the entry is a file."""
117+
118+
is_directory: bool
119+
"""Whether the entry is a directory."""
120+
121+
is_symlink: bool
122+
"""Whether the entry is a symbolic link."""
123+
124+
125+
class FsFileHandle(TypedDict):
126+
file_handle_id: int
127+
128+
34129
class AsyncFsFile:
35130
def __init__(self, rpc: AsyncRpcClient, fd: int):
36131
self._rpc = rpc

src/deno_sandbox/revisions.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
from __future__ import annotations
22

3-
from typing import Any, cast
4-
from typing_extensions import Optional
3+
from typing import Any, TypedDict, cast
4+
from typing_extensions import Literal, Optional
5+
6+
from deno_sandbox.timelines import Timeline
57

6-
from .api_types_generated import (
7-
RevisionWithoutTimelines,
8-
)
98
from .bridge import AsyncBridge
109
from .console import (
1110
AsyncConsoleClient,
1211
AsyncPaginatedList,
1312
PaginatedList,
14-
Revision,
1513
)
1614
from .utils import convert_to_snake_case
1715

1816

17+
class RevisionWithoutTimelines(TypedDict):
18+
id: str
19+
"""The unique identifier for the revision."""
20+
21+
status: Literal["building", "ready", "error"]
22+
"""The status of the revision."""
23+
24+
created_at: str
25+
"""The ISO 8601 timestamp when the revision was created."""
26+
27+
updated_at: str
28+
"""The ISO 8601 timestamp when the revision was last updated."""
29+
30+
31+
class Revision(RevisionWithoutTimelines):
32+
timelines: list[Timeline]
33+
"""The timelines associated with the revision."""
34+
35+
1936
class AsyncRevisions:
2037
def __init__(self, client: AsyncConsoleClient):
2138
self._client = client

src/deno_sandbox/sandbox.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
ProcessSpawnResult,
3333
RemoteProcessOptions,
3434
)
35-
from .api_types_generated import (
36-
SandboxMeta,
37-
)
3835
from .bridge import AsyncBridge
3936
from .console import (
4037
AsyncConsoleClient,
@@ -52,6 +49,23 @@
5249
StdIo: TypeAlias = Literal["piped", "null"]
5350

5451

52+
class SandboxMeta(TypedDict):
53+
id: str
54+
"""The unique identifier for the sandbox."""
55+
56+
created_at: str
57+
"""The ISO 8601 timestamp when the sandbox was created."""
58+
59+
region: str
60+
"""The region the sandbox is located in."""
61+
62+
status: Literal["running", "stopped"]
63+
"""The status of the sandbox."""
64+
65+
stopped_at: NotRequired[str | None]
66+
"""The ISO 8601 timestamp when the sandbox was stopped."""
67+
68+
5569
class SecretConfig(TypedDict):
5670
"""List of hostnames where this secret can be used. Must have at least one host."""
5771

src/deno_sandbox/snapshots.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Any, cast
3+
from typing import Any, TypedDict, cast
44
from typing_extensions import Optional
55

66
from .bridge import AsyncBridge
@@ -10,12 +10,51 @@
1010
PaginatedList,
1111
)
1212

13-
from .api_types_generated import (
14-
Snapshot,
15-
)
1613
from .utils import convert_to_snake_case
1714

1815

16+
class BaseSnapshot(TypedDict):
17+
id: str
18+
"""The unique identifier for the snapshot."""
19+
20+
slug: str
21+
"""Human readable identifier for the snapshot."""
22+
23+
24+
class Snapshot(TypedDict):
25+
id: str
26+
"""The unique identifier for the snapshot."""
27+
28+
slug: str
29+
"""The human readable identifier for the snapshot."""
30+
31+
region: str
32+
"""The region the snapshot is located in."""
33+
34+
allocated_size: int
35+
"""
36+
The number of bytes currently allocated specifically for the snapshot.
37+
38+
Snapshots created from other snapshots only store data that is different
39+
from their base snapshot, so this size may be smaller than the actual size
40+
of the file system on the snapshot.
41+
This is not the total size of the snapshot.
42+
"""
43+
44+
flattened_size: int
45+
"""
46+
The total size of the file system on the snapshot, in bytes. This is the size the snapshot would take up if it were fully "flattened" (i.e., if all data from any snapshots it was created from were fully stored in this snapshot).
47+
48+
Snapshots created from other snapshots only store data that is different from their base snapshot, so this size may be larger than the amount of data actually allocated for the snapshot.
49+
"""
50+
51+
is_bootable: bool
52+
"""Whether the snapshot is bootable."""
53+
54+
base_snapshot: BaseSnapshot
55+
"""The snapshot the volume was created from."""
56+
57+
1958
class AsyncSnapshots:
2059
def __init__(self, client: AsyncConsoleClient):
2160
self._client = client

src/deno_sandbox/timelines.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import Any, TypedDict
44
from typing_extensions import Optional
55

6-
from .api_types_generated import (
7-
Timeline,
8-
)
96

107
from .bridge import AsyncBridge
118
from .console import (
@@ -15,6 +12,38 @@
1512
)
1613

1714

15+
class TimelineApp(TypedDict):
16+
id: str
17+
"""The unique identifier for the app."""
18+
19+
slug: str
20+
"""The human readable identifier for the app."""
21+
22+
23+
class TimelineContext(TypedDict):
24+
slug: str
25+
26+
27+
class Domain(TypedDict):
28+
domain: str
29+
"""The domain name."""
30+
31+
32+
class Timeline(TypedDict):
33+
slug: str
34+
"""The unique identifier for the timeline."""
35+
36+
partition: dict[str, str]
37+
"""The partition of the timeline."""
38+
39+
app: TimelineApp
40+
context: TimelineContext
41+
"""The context of the timeline."""
42+
43+
domains: list[Domain]
44+
"""The domains associated with the timeline."""
45+
46+
1847
class AsyncTimelines:
1948
def __init__(self, client: AsyncConsoleClient):
2049
self._client = client

0 commit comments

Comments
 (0)