From 97077ed32ec8f12ee2013a8d2b7377e259989378 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Tue, 31 Mar 2026 20:14:47 +0800 Subject: [PATCH] test: clean up type: ignore comments and add package markers - Remove unnecessary type: ignore comments in test files - Add __init__.py markers for tests and tests/unit packages --- tests/__init__.py | 1 + tests/agent/test_context_manager.py | 4 ++-- tests/test_discord_platform_adapter.py | 2 +- tests/test_tui_message_handler.py | 2 +- tests/unit/__init__.py | 1 + tests/unit/test_tool_conflict_resolution.py | 4 ++-- tests/unit/test_umop_config_router.py | 4 ++-- 7 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..c80103a70 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +# Package marker for stable pytest module names. diff --git a/tests/agent/test_context_manager.py b/tests/agent/test_context_manager.py index 498227b19..0a0e3d1a8 100644 --- a/tests/agent/test_context_manager.py +++ b/tests/agent/test_context_manager.py @@ -75,7 +75,7 @@ class TestContextManager: """Test initialization with LLM-based compression.""" mock_provider = MockProvider() config = ContextConfig( - llm_compress_provider=mock_provider, # type: ignore + llm_compress_provider=mock_provider, llm_compress_keep_recent=5, llm_compress_instruction="Summarize the conversation", ) @@ -665,7 +665,7 @@ class TestContextManager: """Test LLM compression using MockProvider.""" mock_provider = MockProvider() config = ContextConfig( - llm_compress_provider=mock_provider, # type: ignore + llm_compress_provider=mock_provider, llm_compress_keep_recent=3, llm_compress_instruction="请总结对话内容", max_context_tokens=100, diff --git a/tests/test_discord_platform_adapter.py b/tests/test_discord_platform_adapter.py index a607913c5..5d5c95f28 100644 --- a/tests/test_discord_platform_adapter.py +++ b/tests/test_discord_platform_adapter.py @@ -25,7 +25,7 @@ async def test_collect_and_register_commands_ignores_daily_create_limit() -> Non adapter.client = MockDiscordBuilder.create_client() exc = HTTPException("daily limit") - exc.code = 30034 # type: ignore[attr-defined] + exc.code = 30034 [attr-defined] adapter.client.sync_commands.side_effect = exc await adapter._collect_and_register_commands() diff --git a/tests/test_tui_message_handler.py b/tests/test_tui_message_handler.py index 332b3f233..04023b021 100644 --- a/tests/test_tui_message_handler.py +++ b/tests/test_tui_message_handler.py @@ -225,7 +225,7 @@ class TestSSEMessageParserProcess: parser.process_message( ParsedMessage(type=MessageType.REASONING, data="Thinking...") ) - parser._tool_calls["tc1"] = object() # type: ignore + parser._tool_calls["tc1"] = object() parser.reset() diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 000000000..c80103a70 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1 @@ +# Package marker for stable pytest module names. diff --git a/tests/unit/test_tool_conflict_resolution.py b/tests/unit/test_tool_conflict_resolution.py index 7fd04d448..da571229e 100644 --- a/tests/unit/test_tool_conflict_resolution.py +++ b/tests/unit/test_tool_conflict_resolution.py @@ -83,14 +83,14 @@ class TestToolSetAddTool: parameters = {"type": "object"} mock_tool = MockTool() - toolset.add_tool(mock_tool) # type: ignore + toolset.add_tool(mock_tool) # Should be added successfully assert len(toolset.tools) == 1 # Adding another tool without active should overwrite mock_tool2 = MockTool() - toolset.add_tool(mock_tool2) # type: ignore + toolset.add_tool(mock_tool2) assert len(toolset.tools) == 1 diff --git a/tests/unit/test_umop_config_router.py b/tests/unit/test_umop_config_router.py index 43567deba..0e239d54c 100644 --- a/tests/unit/test_umop_config_router.py +++ b/tests/unit/test_umop_config_router.py @@ -59,8 +59,8 @@ class TestSplitUmo: def test_non_string_returns_none(self): """UMO that is not a string returns None.""" - assert UmopConfigRouter._split_umo(None) is None # type: ignore 故意这样测试的 - assert UmopConfigRouter._split_umo(123) is None # type: ignore 故意这样测试的 + assert UmopConfigRouter._split_umo(None) is None # 故意这样测试的 + assert UmopConfigRouter._split_umo(123) is None # 故意这样测试的 def test_four_parts_returns_three(self): """UMO with four parts splits to three (last keeps colon)."""