Skip to content

Commit 5e7733c

Browse files
rustyconoverclaude
andcommitted
tests: fix the mypy errors that kept CI's Lint job red
Three came with the Orchard hosted-mode tests (a dict of lambdas, an authenticate stub returning None); three predate them (pa.schema of mixed fields inferred as list[object], an on_bind override missing **kwargs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzrG3FzSh28NiZ8UnVtRbk
1 parent 634ead0 commit 5e7733c

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎tests/test_aggregate_function.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ def on_bind(
11451145
params: Any,
11461146
*,
11471147
key: Annotated[dict[str, Any] | None, Secret("s3")] = None,
1148+
**kwargs: Any,
11481149
) -> BindResponse:
11491150
return super().on_bind(params)
11501151

‎tests/test_orchard_hosted.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import time
2727
import urllib.error
2828
import urllib.request
29-
from collections.abc import Iterator
29+
from collections.abc import Callable, Iterator
3030
from dataclasses import dataclass
3131
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
3232
from pathlib import Path
@@ -315,7 +315,7 @@ def test_no_pass_401(self, worker: _Worker, method: str, path: str) -> None:
315315
def test_bad_pass_401(self, worker: _Worker, case: str) -> None:
316316
"""Every invalid Pass gets the same 401."""
317317
now = int(time.time())
318-
token = {
318+
makers: dict[str, Callable[[], str]] = {
319319
"garbage": lambda: "not-a-jwt",
320320
"tampered": lambda: _tamper(_pass(), org_id="org_EVIL"),
321321
"wrong_aud": lambda: _pass(aud="https://desk.orchard.test/d/dep_other"),
@@ -326,7 +326,8 @@ def test_bad_pass_401(self, worker: _Worker, case: str) -> None:
326326
"hs256": lambda: _pass(OctKey.import_key(b"k" * 32, {"kid": "desk-es256-1"}), alg="HS256"),
327327
"wrong_iss": lambda: _pass(iss="https://evil.test"),
328328
"no_exp": lambda: _pass(exp=None),
329-
}[case]()
329+
}
330+
token = makers[case]()
330331
status, headers, _ = _request(
331332
worker, "POST", "/vgi.v3/catalog_attach", _use(token), headers={"Origin": "https://shell.example.com"}
332333
)
@@ -527,14 +528,16 @@ def test_hosted_returns_pass_verifier(self, monkeypatch: pytest.MonkeyPatch) ->
527528

528529
def test_create_app_refuses_custom_authenticate(self, monkeypatch: pytest.MonkeyPatch) -> None:
529530
"""create_app refuses a caller-supplied authenticator in hosted mode."""
531+
from vgi_rpc.rpc import AuthContext
532+
530533
from vgi._test_fixtures.orchard_hosted import OrchardHostedWorker
531534
from vgi.serve import create_app
532535

533536
for key, value in _env(_JWKS).items():
534537
if key.startswith("VGI_"):
535538
monkeypatch.setenv(key, value)
536539
with pytest.raises(SystemExit):
537-
create_app(OrchardHostedWorker, signing_key=b"k" * 32, authenticate=lambda req: None)
540+
create_app(OrchardHostedWorker, signing_key=b"k" * 32, authenticate=lambda req: AuthContext.anonymous())
538541

539542
def test_jwt_algorithms_outside_hosted_mode(self, monkeypatch: pytest.MonkeyPatch) -> None:
540543
"""VGI_JWT_ALGORITHMS also applies to ordinary JWT auth; HS* refuses."""

‎tests/test_worker.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Tests for vgi.worker module, including function overloading and cardinality."""
44

55
from dataclasses import dataclass
6-
from typing import Annotated, Any
6+
from typing import Annotated, Any, cast
77

88
import pyarrow as pa
99
import pytest
@@ -1693,7 +1693,9 @@ def test_two_columns_pick_two_column_overload(self) -> None:
16931693
result = Worker._match_function_arguments(
16941694
function_name="decode",
16951695
arguments=Arguments(positional=()),
1696-
input_schema=pa.schema([("code", pa.string()), ("year", pa.int64())]),
1696+
input_schema=pa.schema(
1697+
cast("list[pa.Field[Any]]", [pa.field("code", pa.string()), pa.field("year", pa.int64())])
1698+
),
16971699
candidates=[one, two],
16981700
)
16991701
assert result is two
@@ -1705,7 +1707,12 @@ def test_three_columns_match_neither(self) -> None:
17051707
Worker._match_function_arguments(
17061708
function_name="decode",
17071709
arguments=Arguments(positional=()),
1708-
input_schema=pa.schema([("a", pa.string()), ("b", pa.int64()), ("c", pa.int64())]),
1710+
input_schema=pa.schema(
1711+
cast(
1712+
"list[pa.Field[Any]]",
1713+
[pa.field("a", pa.string()), pa.field("b", pa.int64()), pa.field("c", pa.int64())],
1714+
)
1715+
),
17091716
candidates=[one, two],
17101717
)
17111718

0 commit comments

Comments
 (0)