Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 66647e4

Browse files
committed
Fix typing issues
1 parent 67d947c commit 66647e4

6 files changed

Lines changed: 41 additions & 5 deletions

File tree

packages/jumpstarter/jumpstarter/client/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Base classes for drivers and driver clients
33
"""
44

5+
from __future__ import annotations
6+
57
import logging
68
from contextlib import asynccontextmanager
79
from dataclasses import dataclass, field

packages/jumpstarter/jumpstarter/client/grpc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from dataclasses import InitVar, dataclass, field
66
from datetime import datetime, timedelta
77
from types import SimpleNamespace
8-
from typing import Any
98

109
from google.protobuf import duration_pb2, field_mask_pb2, json_format, timestamp_pb2
1110
from grpc import ChannelConnectivity
@@ -489,7 +488,7 @@ class MultipathExporterStub:
489488

490489
channels: InitVar[list[Channel]]
491490

492-
__stubs: dict[Channel, Any] = field(init=False, default_factory=OrderedDict)
491+
__stubs: dict[Channel, SimpleNamespace] = field(init=False, default_factory=OrderedDict)
493492

494493
def __post_init__(self, channels):
495494
for channel in channels:
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
from .enums import ExporterStatus, LogSource
22
from .metadata import Metadata
33
from .tempfile import TemporarySocket, TemporaryTcpListener, TemporaryUnixListener
4+
from .types import (
5+
AsyncChannel,
6+
ControllerStub,
7+
ExporterStub,
8+
RouterStub,
9+
)
410

511
__all__ = [
12+
"AsyncChannel",
13+
"ControllerStub",
614
"ExporterStatus",
15+
"ExporterStub",
716
"LogSource",
817
"Metadata",
18+
"RouterStub",
919
"TemporarySocket",
10-
"TemporaryUnixListener",
1120
"TemporaryTcpListener",
21+
"TemporaryUnixListener",
1222
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Type aliases for gRPC and Protobuf types."""
2+
3+
from typing import TYPE_CHECKING, TypeAlias
4+
5+
from grpc.aio import Channel
6+
from jumpstarter_protocol import jumpstarter_pb2_grpc, router_pb2_grpc
7+
8+
# Stub type aliases (the generic Stub classes work for both sync and async)
9+
ExporterStub: TypeAlias = jumpstarter_pb2_grpc.ExporterServiceStub
10+
RouterStub: TypeAlias = router_pb2_grpc.RouterServiceStub
11+
ControllerStub: TypeAlias = jumpstarter_pb2_grpc.ControllerServiceStub
12+
13+
# Channel type alias
14+
AsyncChannel: TypeAlias = Channel
15+
16+
# Async stub type aliases are only available for type checking (defined in .pyi files)
17+
if TYPE_CHECKING:
18+
pass
19+
20+
__all__ = [
21+
"AsyncChannel",
22+
"ControllerStub",
23+
"ExporterStub",
24+
"RouterStub",
25+
]

packages/jumpstarter/jumpstarter/config/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class ClientConfigV1Alpha1(BaseSettings):
120120

121121
leases: ClientConfigV1Alpha1Lease = Field(default_factory=ClientConfigV1Alpha1Lease)
122122

123-
async def channel(self):
123+
async def channel(self) -> grpc.aio.Channel:
124124
if self.endpoint is None or self.token is None:
125125
raise ConfigurationError("endpoint or token not set in client config")
126126

packages/jumpstarter/jumpstarter/config/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async def create_exporter(self):
212212

213213
from jumpstarter.exporter import Exporter
214214

215-
async def channel_factory():
215+
async def channel_factory() -> grpc.aio.Channel:
216216
if self.endpoint is None or self.token is None:
217217
raise ConfigurationError("endpoint or token not set in exporter config")
218218
credentials = grpc.composite_channel_credentials(

0 commit comments

Comments
 (0)