From f52115a22fc458afc0ac7dc76a7ec52928d16209 Mon Sep 17 00:00:00 2001 From: lowyelling Date: Mon, 4 May 2026 14:42:18 -0400 Subject: [PATCH] fix(tests): satisfy basedpyright in test_representation_manager The save-representation tests added in #615 were structurally correct but failed strict typing in two places. Static Analysis has been red on main since the merge. - `mock_save.await_args` is `_Call | None`; assert it's not None before reading `.kwargs` / `.args` so basedpyright can narrow the type - `SimpleNamespace(...)` passed as `message_level_configuration` is an intentional duck-typed mock (only `.dream.enabled` is read by `save_representation`), so opt out at the call site with `# pyright: ignore[reportArgumentType]` rather than constructing a full `ResolvedConfiguration` (matches the existing `reportPrivateUsage` ignore pattern in this file) No runtime behavior changes; `uv run basedpyright` is now clean project-wide. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/crud/test_representation_manager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/crud/test_representation_manager.py b/tests/crud/test_representation_manager.py index dfd959d7..ff49ac07 100644 --- a/tests/crud/test_representation_manager.py +++ b/tests/crud/test_representation_manager.py @@ -24,6 +24,7 @@ async def _fake_tracked_db(_name: str): def _saved_observations(mock_save: AsyncMock): call = mock_save.await_args + assert call is not None, "mock was not awaited" if "all_observations" in call.kwargs: return call.kwargs["all_observations"] if len(call.args) > 1: @@ -162,7 +163,9 @@ class TestRepresentationManagerSoftDelete: class TestRepresentationManagerSave: @pytest.mark.asyncio - async def test_save_representation_filters_blank_observations_before_embedding(self): + async def test_save_representation_filters_blank_observations_before_embedding( + self, + ): manager = RepresentationManager( "workspace", observer="observer", @@ -202,7 +205,7 @@ class TestRepresentationManagerSave: message_ids=[1], session_name="session", message_created_at=datetime.now(timezone.utc), - message_level_configuration=SimpleNamespace( + message_level_configuration=SimpleNamespace( # pyright: ignore[reportArgumentType] dream=SimpleNamespace(enabled=False) ), ) @@ -258,7 +261,7 @@ class TestRepresentationManagerSave: message_ids=[1], session_name="session", message_created_at=datetime.now(timezone.utc), - message_level_configuration=SimpleNamespace( + message_level_configuration=SimpleNamespace( # pyright: ignore[reportArgumentType] dream=SimpleNamespace(enabled=False) ), ) @@ -311,7 +314,7 @@ class TestRepresentationManagerSave: message_ids=[1], session_name="session", message_created_at=datetime.now(timezone.utc), - message_level_configuration=SimpleNamespace( + message_level_configuration=SimpleNamespace( # pyright: ignore[reportArgumentType] dream=SimpleNamespace(enabled=False) ), )