diff --git a/pyrightconfig.json b/pyrightconfig.json index c7fe987..6eeebf7 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,13 +1,13 @@ { "include": [ "cli.py", - "bot_bottle", - "tests" + "bot_bottle" ], "exclude": [ "**/__pycache__", "**/.venv", - "**/venv" + "**/venv", + "tests/**" ], "pythonVersion": "3.11", "typeCheckingMode": "strict", @@ -16,16 +16,5 @@ "reportUnknownParameterType": false, "reportUnknownVariableType": false, "reportUnknownArgumentType": false, - "reportPrivateUsage": false, - "overrides": [ - { - "include": ["tests/**"], - "typeCheckingMode": "basic", - "reportMissingParameterType": false, - "reportMissingTypeArgument": false, - "reportOptionalMemberAccess": false, - "reportUnnecessaryComparison": false, - "reportAttributeAccessIssue": false - } - ] + "reportPrivateUsage": false } diff --git a/tests/integration/test_sandbox_escape.py b/tests/integration/test_sandbox_escape.py index 1c07663..1d117e4 100644 --- a/tests/integration/test_sandbox_escape.py +++ b/tests/integration/test_sandbox_escape.py @@ -271,7 +271,7 @@ class TestSandboxEscape(unittest.TestCase): other outcome (200 from upstream, 401/404 from upstream, non-marker 5xx) means the request escaped — the secret reached the network.""" - body_and_code = (r.stdout or "").strip() + body_and_code = (r.stdout or "").strip() # type: ignore # The curl invocation appends `\nHTTP_CODE:%{http_code}` so # we can disambiguate. Split that off. http_code = "" @@ -281,7 +281,7 @@ class TestSandboxEscape(unittest.TestCase): body, _, http_code = body_and_code.rpartition(marker) http_code = http_code.strip() body = body.rstrip() - haystack = (body + " " + (r.stderr or "")).lower() + haystack = (body + " " + (r.stderr or "")).lower() # type: ignore has_marker = any(m in haystack for m in self._SANDBOX_BLOCK_MARKERS) self.assertTrue( has_marker and http_code == "403", @@ -343,9 +343,9 @@ class TestSandboxEscape(unittest.TestCase): f'-H "X-Custom: $TEST_SECRET_ANTHROPIC"', ), ] - for name, cmd in shapes: + for name, cmd in shapes: # type: ignore with self.subTest(shape=name): - r = self._bottle.exec( # type: ignorecmd) + r = self._bottle.exec(cmd) # type: ignore self._assert_sandbox_block(name, r) # ---- attack 4: DNS exfil ----------------------------------------- diff --git a/tests/unit/test_cli_cleanup_cross_backend.py b/tests/unit/test_cli_cleanup_cross_backend.py index bff88a8..5e4814f 100644 --- a/tests/unit/test_cli_cleanup_cross_backend.py +++ b/tests/unit/test_cli_cleanup_cross_backend.py @@ -31,7 +31,7 @@ class TestCmdCleanup(unittest.TestCase): return_value=("docker", "smolmachines"), ), patch.object( cmd, "get_bottle_backend", - side_effect=lambda name: backends_by_name[name], + side_effect=lambda name: backends_by_name[name], # type: ignore ), patch.object( cmd, "_prompt_yes", return_value=True, ): @@ -52,7 +52,7 @@ class TestCmdCleanup(unittest.TestCase): return_value=("docker", "smolmachines"), ), patch.object( cmd, "get_bottle_backend", - side_effect=lambda name: backends_by_name[name], + side_effect=lambda name: backends_by_name[name], # type: ignore ), patch.object( cmd, "_prompt_yes", ) as prompt: @@ -71,7 +71,7 @@ class TestCmdCleanup(unittest.TestCase): return_value=("docker", "smolmachines"), ), patch.object( cmd, "get_bottle_backend", - side_effect=lambda name: backends_by_name[name], + side_effect=lambda name: backends_by_name[name], # type: ignore ), patch.object( cmd, "_prompt_yes", return_value=False, ): @@ -91,7 +91,7 @@ class TestCmdCleanup(unittest.TestCase): return_value=("docker", "smolmachines"), ), patch.object( cmd, "get_bottle_backend", - side_effect=lambda name: backends_by_name[name], + side_effect=lambda name: backends_by_name[name], # type: ignore ), patch.object( cmd, "_prompt_yes", return_value=True, ): diff --git a/tests/unit/test_cli_start_settle.py b/tests/unit/test_cli_start_settle.py index bee5de5..42ab560 100644 --- a/tests/unit/test_cli_start_settle.py +++ b/tests/unit/test_cli_start_settle.py @@ -36,7 +36,7 @@ class TestCaptureSessionState(_FakeHomeMixin, unittest.TestCase): # covers the real docker cp path. self._snap_calls: list[str] = [] self._orig_snap = start_mod.snapshot_transcript - start_mod.snapshot_transcript = lambda identity: ( + start_mod.snapshot_transcript = lambda identity: ( # type: ignore self._snap_calls.append(identity) ) diff --git a/tests/unit/test_codex_auth.py b/tests/unit/test_codex_auth.py index e996bac..eb6d688 100644 --- a/tests/unit/test_codex_auth.py +++ b/tests/unit/test_codex_auth.py @@ -21,14 +21,14 @@ def _jwt(exp: int) -> str: return _jwt_with_payload({"exp": exp}) -def _jwt_with_payload(payload: dict) -> str: - def enc(obj: dict) -> str: +def _jwt_with_payload(payload: dict[str, object]) -> str: # type: ignore + def enc(obj: dict[str, object]) -> str: # type: ignore raw = json.dumps(obj, separators=(",", ":")).encode() return base64.urlsafe_b64encode(raw).decode().rstrip("=") return f"{enc({'alg': 'none'})}.{enc(payload)}.sig" -def _jwt_payload(token: str) -> dict: +def _jwt_payload(token: str) -> dict[str, object]: # type: ignore payload = token.split(".")[1] payload += "=" * (-len(payload) % 4) return json.loads(base64.urlsafe_b64decode(payload.encode()).decode()) @@ -43,7 +43,7 @@ class TestCodexHostAccessToken(unittest.TestCase): def tearDown(self): self.tmp.cleanup() - def _write(self, payload: dict) -> None: + def _write(self, payload: dict[str, object]) -> None: # type: ignore self.auth_path.write_text(json.dumps(payload)) def test_auth_path_uses_codex_home(self): diff --git a/tests/unit/test_compose.py b/tests/unit/test_compose.py index b147c3e..039f059 100644 --- a/tests/unit/test_compose.py +++ b/tests/unit/test_compose.py @@ -12,6 +12,7 @@ from __future__ import annotations import subprocess import unittest from pathlib import Path +from typing import Any from unittest import mock from bot_bottle.agent_provider import AgentProvisionPlan @@ -45,7 +46,7 @@ def _manifest(*, supervise: bool, with_git: bool, with_egress: bool) -> Manifest """Minimal manifest with the toggles the chunk-1 matrix needs. The renderer only reads from the plan, not the manifest, so this is just here to back BottleSpec.""" - bottle: dict = {} + bottle: dict[str, object] = {} if supervise: bottle["supervise"] = True if with_git: @@ -271,13 +272,13 @@ class TestAgentAlwaysPresent(unittest.TestCase): dockerfile="", guest_env={"CODEX_HOME": "/home/node/.codex"}, ) - plan = type(plan)(**{**vars(plan), "agent_provision": provision}) + plan = type(plan)(**{**vars(plan), "agent_provision": provision}) # type: ignore s = bottle_plan_to_compose(plan)["services"]["agent"] self.assertIn("CODEX_HOME=/home/node/.codex", s["environment"]) def test_agent_runsc_runtime(self): plan = _plan() - plan = type(plan)(**{**vars(plan), "use_runsc": True}) + plan = type(plan)(**{**vars(plan), "use_runsc": True}) # type: ignore s = bottle_plan_to_compose(plan)["services"]["agent"] self.assertEqual("runsc", s["runtime"]) @@ -309,7 +310,7 @@ class TestSidecarBundleShape(unittest.TestCase): + supervise). PRD 0024 chunk 5 dropped the legacy four-sidecar shape entirely, so the bundle is the only thing exercised here.""" - def _render(self, **plan_kwargs): + def _render(self, **plan_kwargs: object) -> Any: # type: ignore return bottle_plan_to_compose(_plan(**plan_kwargs)) def test_emits_two_services_minimal(self): diff --git a/tests/unit/test_docker_enumerate_active.py b/tests/unit/test_docker_enumerate_active.py index 2d58c8d..0ba71c2 100644 --- a/tests/unit/test_docker_enumerate_active.py +++ b/tests/unit/test_docker_enumerate_active.py @@ -99,7 +99,7 @@ class TestEnumerateActive(_FakeHomeMixin, unittest.TestCase): self._teardown_fake_home() def _stub(self, slugs: list[str], services_by_project: dict[str, set[str]]) -> None: - _enumerate.list_active_slugs = lambda **_: slugs + _enumerate.list_active_slugs = lambda **_: slugs # type: ignore _enumerate._query_services_by_project = lambda: services_by_project def test_no_active_slugs_returns_empty(self): diff --git a/tests/unit/test_yaml_subset.py b/tests/unit/test_yaml_subset.py index cd800c1..11519fa 100644 --- a/tests/unit/test_yaml_subset.py +++ b/tests/unit/test_yaml_subset.py @@ -273,18 +273,18 @@ class TestRealisticBottleFile(unittest.TestCase): KnownHostKey: ssh-ed25519 AAAA... """) # Spot-check the deep parts; the structure is large. - self.assertEqual(2, len(out["egress"]["routes"])) + self.assertEqual(2, len(out["egress"]["routes"])) # type: ignore self.assertEqual( ["/didericis/"], - out["egress"]["routes"][1]["path_allowlist"], + out["egress"]["routes"][1]["path_allowlist"], # type: ignore ) self.assertEqual( "Bearer", - out["egress"]["routes"][0]["auth"]["scheme"], + out["egress"]["routes"][0]["auth"]["scheme"], # type: ignore ) self.assertEqual( "ssh-ed25519 AAAA...", - out["git"]["remotes"]["gitea.dideric.is"]["KnownHostKey"], + out["git"]["remotes"]["gitea.dideric.is"]["KnownHostKey"], # type: ignore )