Skip to content

Commit 1ee8e50

Browse files
committed
Add type checking with ty
1 parent ea91ef6 commit 1ee8e50

6 files changed

Lines changed: 83 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Run lints
3333
run: ./scripts/lint
3434

35+
- name: Run type checking
36+
run: uv run ty check
37+
3538
build:
3639
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
3740
timeout-minutes: 10

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dev = [
6363
"pytest-xdist>=3.6.1",
6464
"uuid-utils>=0.11.0",
6565
"pytest-cov>=7.0.0",
66+
"ty>=0.0.1a32",
6667
]
6768
docs = [
6869
"furo>=2025.9.25",
@@ -285,3 +286,26 @@ known-first-party = ["runloop_api_client", "tests"]
285286
"scripts/**.py" = ["T201", "T203"]
286287
"tests/**.py" = ["T201", "T203"]
287288
"examples/**.py" = ["T201", "T203"]
289+
290+
[tool.ty.src]
291+
# External libraries with known stub issues
292+
exclude = [
293+
"tests",
294+
"src/runloop_api_client/resources",
295+
"src/runloop_api_client/_utils",
296+
]
297+
298+
[tool.ty.rules]
299+
invalid-assignment = "ignore"
300+
call-non-callable = "ignore"
301+
redundant-cast = "ignore"
302+
invalid-argument-type = "ignore"
303+
unresolved-attribute = "ignore"
304+
not-iterable = "ignore"
305+
invalid-explicit-override = "ignore"
306+
non-subscriptable = "ignore"
307+
invalid-return-type = "ignore"
308+
unresolved-import = "ignore"
309+
possibly-missing-attribute = "ignore"
310+
invalid-parameter-default = "ignore"
311+
no-matching-overload = "ignore"

src/runloop_api_client/_base_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def iter_pages(self: SyncPageT) -> Iterator[SyncPageT]:
257257
while True:
258258
yield page
259259
if page.has_next_page():
260-
page = page.get_next_page()
260+
page = cast(page.get_next_page()) # type: ignore
261261
else:
262262
return
263263

@@ -486,7 +486,7 @@ def _build_request(
486486
if json_data is None:
487487
json_data = cast(Body, options.extra_json)
488488
elif is_mapping(json_data):
489-
json_data = _merge_mappings(json_data, options.extra_json)
489+
json_data = _merge_mappings(json_data, options.extra_json) # type: ignore
490490
else:
491491
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
492492

@@ -513,7 +513,7 @@ def _build_request(
513513
raise TypeError(
514514
f"Expected query input to be a dictionary for multipart requests but got {type(json_data)} instead."
515515
)
516-
kwargs["data"] = self._serialize_multipartform(json_data)
516+
kwargs["data"] = self._serialize_multipartform(json_data) # type: ignore
517517

518518
# httpx determines whether or not to send a "multipart/form-data"
519519
# request based on the truthiness of the "files" argument.

src/runloop_api_client/sdk/async_.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import asyncio
6-
from typing import Dict, Mapping, Optional
6+
from typing import Dict, List, Mapping, Optional
77
from pathlib import Path
88
from datetime import timedelta
99
from typing_extensions import Unpack
@@ -150,7 +150,7 @@ def from_id(self, devbox_id: str) -> AsyncDevbox:
150150
async def list(
151151
self,
152152
**params: Unpack[SDKDevboxListParams],
153-
) -> list[AsyncDevbox]:
153+
) -> List[AsyncDevbox]:
154154
"""List devboxes accessible to the caller.
155155
156156
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxListParams` for available parameters
@@ -186,7 +186,7 @@ def __init__(self, client: AsyncRunloop) -> None:
186186
async def list(
187187
self,
188188
**params: Unpack[SDKDiskSnapshotListParams],
189-
) -> list[AsyncSnapshot]:
189+
) -> List[AsyncSnapshot]:
190190
"""List snapshots created from devboxes.
191191
192192
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDiskSnapshotListParams` for available parameters
@@ -277,7 +277,7 @@ def from_id(self, blueprint_id: str) -> AsyncBlueprint:
277277
async def list(
278278
self,
279279
**params: Unpack[SDKBlueprintListParams],
280-
) -> list[AsyncBlueprint]:
280+
) -> List[AsyncBlueprint]:
281281
"""List available blueprints.
282282
283283
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKBlueprintListParams` for available parameters
@@ -338,7 +338,7 @@ def from_id(self, object_id: str) -> AsyncStorageObject:
338338
async def list(
339339
self,
340340
**params: Unpack[SDKObjectListParams],
341-
) -> list[AsyncStorageObject]:
341+
) -> List[AsyncStorageObject]:
342342
"""List storage objects owned by the caller.
343343
344344
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKObjectListParams` for available parameters
@@ -541,12 +541,12 @@ def from_id(self, scorer_id: str) -> AsyncScorer:
541541
"""
542542
return AsyncScorer(self._client, scorer_id)
543543

544-
async def list(self, **params: Unpack[SDKScorerListParams]) -> list[AsyncScorer]:
544+
async def list(self, **params: Unpack[SDKScorerListParams]) -> List[AsyncScorer]:
545545
"""List all scorers, optionally filtered by parameters.
546546
547547
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScorerListParams` for available parameters
548548
:return: List of scorers
549-
:rtype: list[AsyncScorer]
549+
:rtype: List[AsyncScorer]
550550
"""
551551
page = await self._client.scenarios.scorers.list(**params)
552552
return [AsyncScorer(self._client, item.id) async for item in page]
@@ -599,7 +599,7 @@ async def create_from_npm(
599599
package_name: str,
600600
npm_version: Optional[str] = None,
601601
registry_url: Optional[str] = None,
602-
agent_setup: Optional[list[str]] = None,
602+
agent_setup: Optional[List[str]] = None,
603603
**params: Unpack[SDKAgentCreateParams],
604604
) -> AsyncAgent:
605605
"""Create an agent from an NPM package.
@@ -641,7 +641,7 @@ async def create_from_pip(
641641
package_name: str,
642642
pip_version: Optional[str] = None,
643643
registry_url: Optional[str] = None,
644-
agent_setup: Optional[list[str]] = None,
644+
agent_setup: Optional[List[str]] = None,
645645
**params: Unpack[SDKAgentCreateParams],
646646
) -> AsyncAgent:
647647
"""Create an agent from a Pip package.
@@ -682,7 +682,7 @@ async def create_from_git(
682682
*,
683683
repository: str,
684684
ref: Optional[str] = None,
685-
agent_setup: Optional[list[str]] = None,
685+
agent_setup: Optional[List[str]] = None,
686686
**params: Unpack[SDKAgentCreateParams],
687687
) -> AsyncAgent:
688688
"""Create an agent from a Git repository.
@@ -718,7 +718,7 @@ async def create_from_object(
718718
self,
719719
*,
720720
object_id: str,
721-
agent_setup: Optional[list[str]] = None,
721+
agent_setup: Optional[List[str]] = None,
722722
**params: Unpack[SDKAgentCreateParams],
723723
) -> AsyncAgent:
724724
"""Create an agent from a storage object.
@@ -759,7 +759,7 @@ def from_id(self, agent_id: str) -> AsyncAgent:
759759
async def list(
760760
self,
761761
**params: Unpack[SDKAgentListParams],
762-
) -> list[AsyncAgent]:
762+
) -> List[AsyncAgent]:
763763
"""List agents accessible to the caller.
764764
765765
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentListParams` for available parameters
@@ -800,7 +800,7 @@ def from_id(self, scenario_id: str) -> AsyncScenario:
800800
"""
801801
return AsyncScenario(self._client, scenario_id)
802802

803-
async def list(self, **params: Unpack[SDKScenarioListParams]) -> list[AsyncScenario]:
803+
async def list(self, **params: Unpack[SDKScenarioListParams]) -> List[AsyncScenario]:
804804
"""List all scenarios, optionally filtered by parameters.
805805
806806
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScenarioListParams` for available parameters

src/runloop_api_client/sdk/sync.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, Mapping, Optional
5+
from typing import Dict, List, Mapping, Optional
66
from pathlib import Path
77
from datetime import timedelta
88
from typing_extensions import Unpack
@@ -149,7 +149,7 @@ def from_id(self, devbox_id: str) -> Devbox:
149149
def list(
150150
self,
151151
**params: Unpack[SDKDevboxListParams],
152-
) -> list[Devbox]:
152+
) -> List[Devbox]:
153153
"""List devboxes accessible to the caller.
154154
155155
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxListParams` for available parameters
@@ -185,7 +185,7 @@ def __init__(self, client: Runloop) -> None:
185185
def list(
186186
self,
187187
**params: Unpack[SDKDiskSnapshotListParams],
188-
) -> list[Snapshot]:
188+
) -> List[Snapshot]:
189189
"""List snapshots created from devboxes.
190190
191191
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDiskSnapshotListParams` for available parameters
@@ -275,7 +275,7 @@ def from_id(self, blueprint_id: str) -> Blueprint:
275275
def list(
276276
self,
277277
**params: Unpack[SDKBlueprintListParams],
278-
) -> list[Blueprint]:
278+
) -> List[Blueprint]:
279279
"""List available blueprints.
280280
281281
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKBlueprintListParams` for available parameters
@@ -336,7 +336,7 @@ def from_id(self, object_id: str) -> StorageObject:
336336
def list(
337337
self,
338338
**params: Unpack[SDKObjectListParams],
339-
) -> list[StorageObject]:
339+
) -> List[StorageObject]:
340340
"""List storage objects owned by the caller.
341341
342342
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKObjectListParams` for available parameters
@@ -536,7 +536,7 @@ def from_id(self, scorer_id: str) -> Scorer:
536536
"""
537537
return Scorer(self._client, scorer_id)
538538

539-
def list(self, **params: Unpack[SDKScorerListParams]) -> list[Scorer]:
539+
def list(self, **params: Unpack[SDKScorerListParams]) -> List[Scorer]:
540540
"""List all scorers, optionally filtered by parameters.
541541
542542
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScorerListParams` for available parameters
@@ -594,7 +594,7 @@ def create_from_npm(
594594
package_name: str,
595595
npm_version: Optional[str] = None,
596596
registry_url: Optional[str] = None,
597-
agent_setup: Optional[list[str]] = None,
597+
agent_setup: Optional[List[str]] = None,
598598
**params: Unpack[SDKAgentCreateParams],
599599
) -> Agent:
600600
"""Create an agent from an NPM package.
@@ -641,7 +641,7 @@ def create_from_pip(
641641
package_name: str,
642642
pip_version: Optional[str] = None,
643643
registry_url: Optional[str] = None,
644-
agent_setup: Optional[list[str]] = None,
644+
agent_setup: Optional[List[str]] = None,
645645
**params: Unpack[SDKAgentCreateParams],
646646
) -> Agent:
647647
"""Create an agent from a Pip package.
@@ -687,7 +687,7 @@ def create_from_git(
687687
*,
688688
repository: str,
689689
ref: Optional[str] = None,
690-
agent_setup: Optional[list[str]] = None,
690+
agent_setup: Optional[List[str]] = None,
691691
**params: Unpack[SDKAgentCreateParams],
692692
) -> Agent:
693693
"""Create an agent from a Git repository.
@@ -731,7 +731,7 @@ def create_from_object(
731731
self,
732732
*,
733733
object_id: str,
734-
agent_setup: Optional[list[str]] = None,
734+
agent_setup: Optional[List[str]] = None,
735735
**params: Unpack[SDKAgentCreateParams],
736736
) -> Agent:
737737
"""Create an agent from a storage object.
@@ -780,7 +780,7 @@ def from_id(self, agent_id: str) -> Agent:
780780
def list(
781781
self,
782782
**params: Unpack[SDKAgentListParams],
783-
) -> list[Agent]:
783+
) -> List[Agent]:
784784
"""List agents accessible to the caller.
785785
786786
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentListParams` for available parameters
@@ -821,7 +821,7 @@ def from_id(self, scenario_id: str) -> Scenario:
821821
"""
822822
return Scenario(self._client, scenario_id)
823823

824-
def list(self, **params: Unpack[SDKScenarioListParams]) -> list[Scenario]:
824+
def list(self, **params: Unpack[SDKScenarioListParams]) -> List[Scenario]:
825825
"""List all scenarios, optionally filtered by parameters.
826826
827827
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScenarioListParams` for available parameters

uv.lock

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)