Skip to content

Commit 13f2184

Browse files
committed
style: apply ruff formatting and type annotation modernization
1 parent 93cf425 commit 13f2184

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎pylet/aio/__init__.py‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async def main():
1313
"""
1414

1515
import shlex
16-
from typing import Dict, List, Optional, Union
16+
from typing import Any, Optional, Union
1717

1818
import httpx
1919

@@ -28,17 +28,19 @@ async def main():
2828
from pylet.aio._instance import Instance
2929
from pylet.errors import NotFoundError, NotInitializedError
3030

31-
# Re-export Instance for type hints
31+
# Re-export for public API
3232
__all__ = [
33+
"Instance",
34+
"NotFoundError",
35+
"NotInitializedError",
36+
"WorkerInfo",
37+
"get",
3338
"init",
34-
"shutdown",
39+
"instances",
3540
"is_initialized",
41+
"shutdown",
3642
"submit",
37-
"get",
38-
"instances",
3943
"workers",
40-
"Instance",
41-
"WorkerInfo",
4244
]
4345

4446

@@ -91,18 +93,17 @@ def is_initialized() -> bool:
9193

9294

9395
async def submit(
94-
command: Union[str, List[str]],
96+
command: Union[str, list[str]],
9597
*,
9698
name: Optional[str] = None,
9799
gpu: int = 0,
98100
cpu: int = 1,
99101
memory: int = 512,
100-
# SLLM support parameters
101102
target_worker: Optional[str] = None,
102-
gpu_indices: Optional[List[int]] = None,
103+
gpu_indices: Optional[list[int]] = None,
103104
exclusive: bool = True,
104-
labels: Optional[Dict[str, str]] = None,
105-
env: Optional[Dict[str, str]] = None,
105+
labels: Optional[dict[str, str]] = None,
106+
env: Optional[dict[str, str]] = None,
106107
# Venv support
107108
venv: Optional[str] = None,
108109
) -> Instance:
@@ -137,7 +138,7 @@ async def submit(
137138
command = shlex.join(command)
138139

139140
# Build submission request
140-
submission = {
141+
submission: dict[str, Any] = {
141142
"command": command,
142143
"resource_requirements": {
143144
"cpu_cores": cpu,
@@ -213,7 +214,7 @@ async def get(
213214
async def instances(
214215
*,
215216
status: Optional[str] = None,
216-
) -> List[Instance]:
217+
) -> list[Instance]:
217218
"""
218219
List all instances.
219220
@@ -239,7 +240,7 @@ async def instances(
239240
return [Instance(data) for data in response.json()]
240241

241242

242-
async def workers() -> List[WorkerInfo]:
243+
async def workers() -> list[WorkerInfo]:
243244
"""
244245
List all registered workers.
245246

‎pylet/aio/_instance.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import asyncio
8-
from typing import Any, Dict, Optional
8+
from typing import Any, Optional
99

1010
from pylet._state import _get_async_client, _get_head_address
1111
from pylet.errors import (
@@ -14,7 +14,6 @@
1414
TimeoutError,
1515
)
1616

17-
1817
# Terminal states
1918
TERMINAL_STATES = frozenset({"COMPLETED", "FAILED", "CANCELLED"})
2019

@@ -27,7 +26,7 @@ class Instance:
2726
Wait methods automatically refresh.
2827
"""
2928

30-
def __init__(self, data: Dict[str, Any]):
29+
def __init__(self, data: dict[str, Any]):
3130
"""
3231
Initialize instance from server data.
3332
@@ -97,7 +96,7 @@ async def wait_running(self, timeout: float = 300) -> None:
9796
if self.status in TERMINAL_STATES:
9897
raise InstanceFailedError(
9998
f"Instance entered {self.status} state while waiting for RUNNING",
100-
instance=self,
99+
instance=self, # type: ignore[arg-type]
101100
)
102101

103102
await asyncio.sleep(min(poll_interval, timeout - elapsed))

0 commit comments

Comments
 (0)