Skip to content

Commit c381201

Browse files
chore(internal): add --fix argument to lint script
1 parent 9b434d9 commit c381201

8 files changed

Lines changed: 33 additions & 25 deletions

File tree

scripts/lint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7+
echo "==> Running pyright"
8+
uv run pyright
9+
10+
echo "==> Running mypy"
11+
uv run mypy .
12+
713
echo "==> Running lints"
814
uv run ruff check . "$@"
915

src/runloop_api_client/_base_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,21 +1303,21 @@ def __init__(self, **kwargs: Any) -> None:
13031303

13041304

13051305
try:
1306-
import httpx_aiohttp
1306+
import httpx_aiohttp # type: ignore[import-not-found]
13071307
except ImportError:
13081308

13091309
class _DefaultAioHttpClient(httpx.AsyncClient):
13101310
def __init__(self, **_kwargs: Any) -> None:
13111311
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
13121312
else:
13131313

1314-
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
1314+
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore[misc, no-redef]
13151315
def __init__(self, **kwargs: Any) -> None:
13161316
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
13171317
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
13181318
kwargs.setdefault("follow_redirects", True)
13191319

1320-
super().__init__(**kwargs)
1320+
super().__init__(**kwargs) # type: ignore[unknown-call]
13211321

13221322

13231323
if TYPE_CHECKING:

src/runloop_api_client/sdk/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class PollingRequestOptions(BaseRequestOptions, total=False):
7575
"""Configuration for polling behavior"""
7676

7777

78-
class LongPollingRequestOptions(LongRequestOptions, PollingRequestOptions):
78+
class LongPollingRequestOptions(LongRequestOptions, PollingRequestOptions): # type: ignore[misc]
7979
pass
8080

8181

src/runloop_api_client/sdk/agent.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def get_info(
6464
:return: Agent details
6565
:rtype: AgentView
6666
"""
67-
if self._agent_view is None:
68-
self._agent_view = self._client.agents.retrieve(
69-
self._id,
70-
**options,
71-
)
72-
return self._agent_view
67+
return self._client.agents.retrieve(
68+
self._id,
69+
**options,
70+
)

src/runloop_api_client/sdk/async_agent.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,3 @@ async def get_info(
6868
self._id,
6969
**options,
7070
)
71-
if self._agent_view is None:
72-
self._agent_view = self._client.agents.retrieve(
73-
self._id,
74-
**options,
75-
)
76-
return self._agent_view

src/runloop_api_client/sdk/devbox.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,8 @@ def exec(
446446
execution.execution_id,
447447
**filter_params(params, ExecuteStreamingCallbacks),
448448
)
449-
final = execution
450-
if execution.status == "completed":
451-
final: DevboxAsyncExecutionDetailView = execution
452-
else:
449+
final: DevboxAsyncExecutionDetailView = execution
450+
if execution.status != "completed":
453451
final = client.devboxes.executions.await_completed(
454452
execution.execution_id,
455453
devbox_id=devbox.id,

tests/sdk/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Shared fixtures and utilities for SDK tests."""
2+
# pyright: reportUnknownVariableType=false
23

34
from __future__ import annotations
45

tests/sdk/test_ops.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,17 @@ def test_list(self, mock_client: Mock) -> None:
769769
page = SimpleNamespace(agents=[agent_view_1, agent_view_2, agent_view_3])
770770
mock_client.agents.list.return_value = page
771771

772+
# Mock retrieve to return the corresponding agent_view when called
773+
def mock_retrieve(agent_id: str, **_kwargs: object) -> MockAgentView:
774+
agent_views = {
775+
"agent_001": agent_view_1,
776+
"agent_002": agent_view_2,
777+
"agent_003": agent_view_3,
778+
}
779+
return agent_views[agent_id]
780+
781+
mock_client.agents.retrieve.side_effect = mock_retrieve
782+
772783
client = AgentOps(mock_client)
773784
agents = client.list(
774785
limit=10,
@@ -784,32 +795,32 @@ def test_list(self, mock_client: Mock) -> None:
784795
assert agents[1].id == "agent_002"
785796
assert agents[2].id == "agent_003"
786797

787-
# Test that get_info() retrieves the cached AgentView for the first agent
798+
# Test that get_info() retrieves the AgentView for the first agent
788799
info = agents[0].get_info()
789800
assert info.id == "agent_001"
790801
assert info.name == "first-agent"
791802
assert info.create_time_ms == 1234567890000
792803
assert info.is_public is False
793804
assert info.source is None
794805

795-
# Test that get_info() retrieves the cached AgentView for the second agent
806+
# Test that get_info() retrieves the AgentView for the second agent
796807
info = agents[1].get_info()
797808
assert info.id == "agent_002"
798809
assert info.name == "second-agent"
799810
assert info.create_time_ms == 1234567891000
800811
assert info.is_public is True
801812
assert info.source == {"type": "git", "git": {"repository": "https://github.com/example/repo"}}
802813

803-
# Test that get_info() retrieves the cached AgentView for the third agent
814+
# Test that get_info() retrieves the AgentView for the third agent
804815
info = agents[2].get_info()
805816
assert info.id == "agent_003"
806817
assert info.name == "third-agent"
807818
assert info.create_time_ms == 1234567892000
808819
assert info.is_public is False
809820
assert info.source == {"type": "npm", "npm": {"package_name": "example-package"}}
810821

811-
# Verify that agents.retrieve was NOT called (because we're using cached data)
812-
mock_client.agents.retrieve.assert_not_called()
822+
# Verify that agents.retrieve was called for each agent
823+
assert mock_client.agents.retrieve.call_count == 3
813824

814825
mock_client.agents.list.assert_called_once()
815826

0 commit comments

Comments
 (0)