Skip to content

Commit 41f059d

Browse files
committed
fix: fix lint
1 parent 585a0d8 commit 41f059d

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ jobs:
4545
run: uv run ruff check . && uv run ruff format --check .
4646

4747
- name: Run Pyright (Type Check)
48-
run: uv run pyright .
48+
run: uv run pyright sandbox
4949

tests/test_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_sandbox_run_function_invalid_json_output(mocked_sandbox_factory):
189189
create_sandbox, mock_runner = mocked_sandbox_factory
190190
invalid_stdout = "This is not JSON { invalid"
191191
mock_runner.execute_script.return_value = Result(
192-
stdout=invalid_stdout, stderr="", error=None
192+
stdout=invalid_stdout, stderr="", error=None, result=None
193193
)
194194
with create_sandbox() as sandbox:
195195
result = sandbox.run_function(

tests/test_subprocess_runner.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def runner() -> SubprocessSandboxRunner:
3030
def test_subprocess_runner_simple_script(runner: SubprocessSandboxRunner):
3131
"""Test running a simple script."""
3232
result = runner.execute_script(SIMPLE_SCRIPT)
33+
assert "stdout" in result
34+
assert "stderr" in result
35+
assert "error" in result
3336
assert "Hello from subprocess!" in result["stdout"]
3437
assert result["stderr"] == ""
3538
assert result["error"] is None
@@ -38,15 +41,21 @@ def test_subprocess_runner_simple_script(runner: SubprocessSandboxRunner):
3841
def test_subprocess_runner_json_output(runner: SubprocessSandboxRunner):
3942
"""Test script outputting JSON."""
4043
result = runner.execute_script(JSON_OUTPUT_SCRIPT)
44+
assert "stdout" in result
45+
assert "stderr" in result
46+
assert "error" in result
4147
assert '"result": 42' in result["stdout"]
4248
assert result["error"] is None
4349

4450

4551
def test_subprocess_runner_failing_script(runner: SubprocessSandboxRunner):
4652
"""Test running a script that raises an exception."""
4753
result = runner.execute_script(FAILING_SCRIPT)
54+
assert "stdout" in result
55+
assert "stderr" in result
4856
assert result["stdout"] == ""
4957
assert "ValueError: Intentional fail" in result["stderr"]
58+
assert "error" in result
5059
assert result["error"] is not None
5160
assert "exit code 1" in result["error"]
5261

@@ -59,9 +68,10 @@ def test_subprocess_runner_timeout_expires(runner: SubprocessSandboxRunner):
5968
result = timeout_runner.execute_script(SLEEP_SCRIPT) # This script takes 2s
6069
end_time = time.monotonic()
6170

71+
assert "error" in result
6272
assert result["error"] is not None
6373
assert "timed out" in result["error"]
64-
assert "TimeoutExpired" in result["stderr"]
74+
assert "stderr" in result and "TimeoutExpired" in result["stderr"]
6575
# Check if it actually timed out reasonably close to the limit
6676
assert end_time - start_time < 1.5 # Should be around 0.5s + overhead
6777

@@ -73,8 +83,8 @@ def test_subprocess_runner_timeout_sufficient(runner: SubprocessSandboxRunner):
7383
result = runner.execute_script(SLEEP_SCRIPT)
7484
end_time = time.monotonic()
7585

76-
assert result["error"] is None
77-
assert "Done sleeping" in result["stdout"]
86+
assert "error" in result and result["error"] is None
87+
assert "Done sleeping" in result["stdout"] # pyright: ignore [reportTypedDictNotRequiredAccess]
7888
assert end_time - start_time >= 2.0 # Ensure it actually slept
7989

8090

@@ -102,8 +112,8 @@ def test_subprocess_runner_with_deps():
102112
print(json.dumps({"error": str(e)}))
103113
"""
104114
result = runner.execute_script(script_with_header)
105-
assert result["error"] is None, f"Execution failed: {result['stderr']}"
106-
assert '"result": 200' in result["stdout"] or '"error":' in result["stdout"]
115+
assert result["error"] is None, f"Execution failed: {result['stderr']}" # pyright: ignore [reportTypedDictNotRequiredAccess]
116+
assert '"result": 200' in result["stdout"] or '"error":' in result["stdout"] # pyright: ignore [reportTypedDictNotRequiredAccess]
107117

108118

109119
def test_subprocess_runner_uv_not_found():

0 commit comments

Comments
 (0)