Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): enable strict typing for RAG extractor, embedding and retrieval tests (#43913)
Eddy ZHANG2e8b23c47b55
diff --git a/api/tests/unit_tests/core/rag/embedding/test_embedding_base.py b/api/tests/unit_tests/core/rag/embedding/test_embedding_base.pyindex 493a6f5374f..83ddc10739c 100644--- a/api/tests/unit_tests/core/rag/embedding/test_embedding_base.py+++ b/api/tests/unit_tests/core/rag/embedding/test_embedding_base.py@@ -29,81 +29,101 @@ class ConcreteEmbeddings(Embeddings):return [1.0] * 10+class _SuperCallingEmbeddings(Embeddings):+ """Overrides each abstract method by delegating to the Embeddings base implementation."""++ @override+ def embed_documents(self, texts: list[str]) -> list[list[float]]:+ return super().embed_documents(texts)++ @override+ def embed_multimodal_documents(self, multimodel_documents: list[dict[str, Any]]) -> list[list[float]]:+ return super().embed_multimodal_documents(multimodel_documents)++ @override+ def embed_query(self, text: str) -> list[float]:+ return super().embed_query(text)++ @override+ def embed_multimodal_query(self, multimodel_document: dict[str, Any]) -> list[float]:+ return super().embed_multimodal_query(multimodel_document)++class TestEmbeddingsBase:"""Test suite for the abstract Embeddings base class."""- def test_embeddings_is_abc(self):+ def test_embeddings_is_abc(self) -> None:"""Test that Embeddings is an abstract base class."""assert hasattr(Embeddings, "__abstractmethods__")assert len(Embeddings.__abstractmethods__) > 0- def test_embed_documents_is_abstract(self):+ def test_embed_documents_is_abstract(self) -> None:"""Test that embed_documents is an abstract method."""assert "embed_documents" in Embeddings.__abstractmethods__- def test_embed_multimodal_documents_is_abstract(self):+ def test_embed_multimodal_documents_is_abstract(self) -> None:"""Test that embed_multimodal_documents is an abstract method."""assert "embed_multimodal_documents" in Embeddings.__abstractmethods__- def test_embed_query_is_abstract(self):+ def test_embed_query_is_abstract(self) -> None:"""Test that embed_query is an abstract method."""assert "embed_query" in Embeddings.__abstractmethods__- def test_embed_multimodal_query_is_abstract(self):+ def test_embed_multimodal_query_is_abstract(self) -> None:"""Test that embed_multimodal_query is an abstract method."""assert "embed_multimodal_query" in Embeddings.__abstractmethods__- def test_embed_documents_raises_not_implemented(self):+ def test_embed_documents_raises_not_implemented(self) -> None:"""Test that embed_documents raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.embed_documents)assert "raise NotImplementedError" in source- def test_embed_multimodal_documents_raises_not_implemented(self):+ def test_embed_multimodal_documents_raises_not_implemented(self) -> None:"""Test that embed_multimodal_documents raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.embed_multimodal_documents)assert "raise NotImplementedError" in source- def test_embed_query_raises_not_implemented(self):+ def test_embed_query_raises_not_implemented(self) -> None:"""Test that embed_query raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.embed_query)assert "raise NotImplementedError" in source- def test_embed_multimodal_query_raises_not_implemented(self):+ def test_embed_multimodal_query_raises_not_implemented(self) -> None:"""Test that embed_multimodal_query raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.embed_multimodal_query)assert "raise NotImplementedError" in source- def test_aembed_documents_raises_not_implemented(self):+ def test_aembed_documents_raises_not_implemented(self) -> None:"""Test that aembed_documents raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.aembed_documents)assert "raise NotImplementedError" in source- def test_aembed_query_raises_not_implemented(self):+ def test_aembed_query_raises_not_implemented(self) -> None:"""Test that aembed_query raises NotImplementedError in its body."""source = inspect.getsource(Embeddings.aembed_query)assert "raise NotImplementedError" in source- def test_concrete_implementation_works(self):+ def test_concrete_implementation_works(self) -> None:"""Test that a concrete implementation of Embeddings works correctly."""concrete = ConcreteEmbeddings()result = concrete.embed_documents(["test1", "test2"])assert len(result) == 2assert all(len(emb) == 10 for emb in result)- def test_concrete_implementation_embed_query(self):+ def test_concrete_implementation_embed_query(self) -> None:"""Test concrete implementation of embed_query."""concrete = ConcreteEmbeddings()result = concrete.embed_query("test query")assert len(result) == 10- def test_concrete_implementation_embed_multimodal_documents(self):+ def test_concrete_implementation_embed_multimodal_documents(self) -> None:"""Test concrete implementation of embed_multimodal_documents."""concrete = ConcreteEmbeddings()docs: list[dict[str, Any]] = [{"file_id": "file1"}, {"file_id": "file2"}]result = concrete.embed_multimodal_documents(docs)assert len(result) == 2- def test_concrete_implementation_embed_multimodal_query(self):+ def test_concrete_implementation_embed_multimodal_query(self) -> None:"""Test concrete implementation of embed_multimodal_query."""concrete = ConcreteEmbeddings()result = concrete.embed_multimodal_query({"file_id": "test"})@@ -113,111 +133,51 @@ class TestEmbeddingsBase:class TestEmbeddingsNotImplemented:"""Test that abstract methods raise NotImplementedError when called."""- def test_embed_query_raises_not_implemented(self):+ def test_embed_query_raises_not_implemented(self) -> None:"""Test that embed_query raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)-- partial = PartialImpl()+ partial = _SuperCallingEmbeddings()with pytest.raises(NotImplementedError):partial.embed_query("test")- def test_embed_documents_raises_not_implemented(self):+ def test_embed_documents_raises_not_implemented(self) -> None:"""Test that embed_documents raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)-- partial = PartialImpl()+ partial = _SuperCallingEmbeddings()with pytest.raises(NotImplementedError):partial.embed_documents(["test"])- def test_embed_multimodal_documents_raises_not_implemented(self):+ def test_embed_multimodal_documents_raises_not_implemented(self) -> None:"""Test that embed_multimodal_documents raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)-- partial = PartialImpl()+ partial = _SuperCallingEmbeddings()with pytest.raises(NotImplementedError):partial.embed_multimodal_documents([{"file_id": "test"}])- def test_embed_multimodal_query_raises_not_implemented(self):+ def test_embed_multimodal_query_raises_not_implemented(self) -> None:"""Test that embed_multimodal_query raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)-- partial = PartialImpl()+ partial = _SuperCallingEmbeddings()with pytest.raises(NotImplementedError):partial.embed_multimodal_query({"file_id": "test"})- def test_aembed_documents_raises_not_implemented(self):+ def test_aembed_documents_raises_not_implemented(self) -> None:"""Test that aembed_documents raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)+ partial = _SuperCallingEmbeddings()- partial = PartialImpl()-- async def run_test():+ async def run_test() -> None:with pytest.raises(NotImplementedError):await partial.aembed_documents(["test"])asyncio.run(run_test())- def test_aembed_query_raises_not_implemented(self):+ def test_aembed_query_raises_not_implemented(self) -> None:"""Test that aembed_query raises NotImplementedError."""- class PartialImpl:- pass-- PartialImpl.embed_query = lambda self, text: Embeddings.embed_query(self, text)- PartialImpl.embed_documents = lambda self, texts: Embeddings.embed_documents(self, texts)- PartialImpl.embed_multimodal_documents = lambda self, docs: Embeddings.embed_multimodal_documents(self, docs)- PartialImpl.embed_multimodal_query = lambda self, doc: Embeddings.embed_multimodal_query(self, doc)- PartialImpl.aembed_documents = lambda self, texts: Embeddings.aembed_documents(self, texts)- PartialImpl.aembed_query = lambda self, text: Embeddings.aembed_query(self, text)-- partial = PartialImpl()+ partial = _SuperCallingEmbeddings()- async def run_test():+ async def run_test() -> None:with pytest.raises(NotImplementedError):await partial.aembed_query("test")diff --git a/api/tests/unit_tests/core/rag/extractor/test_extractor_base.py b/api/tests/unit_tests/core/rag/extractor/test_extractor_base.pyindex 1d5f27181b7..5ce57f3403b 100644--- a/api/tests/unit_tests/core/rag/extractor/test_extractor_base.py+++ b/api/tests/unit_tests/core/rag/extractor/test_extractor_base.py@@ -4,23 +4,23 @@ from core.rag.extractor.extractor_base import BaseExtractorclass _CallsBaseExtractor(BaseExtractor):- def extract(self):+ def extract(self) -> object:return super().extract()class _ConcreteExtractor(BaseExtractor):- def extract(self):+ def extract(self) -> list[str]:return ["ok"]class TestBaseExtractor:- def test_extract_default_raises_not_implemented(self):+ def test_extract_default_raises_not_implemented(self) -> None:extractor = _CallsBaseExtractor()with pytest.raises(NotImplementedError):extractor.extract()- def test_concrete_extractor_can_override(self):+ def test_concrete_extractor_can_override(self) -> None:extractor = _ConcreteExtractor()assert extractor.extract() == ["ok"]diff --git a/api/tests/unit_tests/core/rag/extractor/test_jina_reader_extractor.py b/api/tests/unit_tests/core/rag/extractor/test_jina_reader_extractor.pyindex 79fcac2f88b..803cd9e5aae 100644--- a/api/tests/unit_tests/core/rag/extractor/test_jina_reader_extractor.py+++ b/api/tests/unit_tests/core/rag/extractor/test_jina_reader_extractor.py@@ -8,7 +8,7 @@ from services.data_source.website_service import WebsiteServiceclass TestJinaReaderWebExtractor:- def test_extract_crawl_mode_returns_document(self, mocker: MockerFixture):+ def test_extract_crawl_mode_returns_document(self, mocker: MockerFixture) -> None:mocker.patch("core.rag.extractor.jina_reader_extractor.WebsiteService.get_crawl_url_data",return_value={@@ -36,7 +36,7 @@ class TestJinaReaderWebExtractor:"title": "title",}- def test_extract_crawl_mode_with_missing_data_returns_empty(self, mocker: MockerFixture):+ def test_extract_crawl_mode_with_missing_data_returns_empty(self, mocker: MockerFixture) -> None:mocker.patch("core.rag.extractor.jina_reader_extractor.WebsiteService.get_crawl_url_data",return_value=None,@@ -52,7 +52,7 @@ class TestJinaReaderWebExtractor:assert extractor.extract() == []- def test_extract_non_crawl_mode_returns_empty(self, mocker: MockerFixture):+ def test_extract_non_crawl_mode_returns_empty(self, mocker: MockerFixture) -> None:mock_get_crawl = mocker.patch("core.rag.extractor.jina_reader_extractor.WebsiteService.get_crawl_url_data",return_value={"content": "unused"},diff --git a/api/tests/unit_tests/core/rag/extractor/test_notion_extractor.py b/api/tests/unit_tests/core/rag/extractor/test_notion_extractor.pyindex 2eac243de8c..1bbeb00f260 100644--- a/api/tests/unit_tests/core/rag/extractor/test_notion_extractor.py+++ b/api/tests/unit_tests/core/rag/extractor/test_notion_extractor.py@@ -26,7 +26,7 @@ def persisted_document(sqlite_engine: Engine,) -> Iterator[tuple[sessionmaker[Session], DocumentModel]]:"""Persist a Notion document and bind the extractor's ``db.session`` to SQLite."""- TypeBase.metadata.create_all(sqlite_engine, tables=[DocumentModel.__table__])+ TypeBase.metadata.create_all(sqlite_engine, tables=[TypeBase.metadata.tables[DocumentModel.__tablename__]])session_maker = sessionmaker(bind=sqlite_engine, expire_on_commit=False)document = DocumentModel(id=str(uuid.uuid4()),@@ -49,7 +49,7 @@ def persisted_document(yield session_maker, document-def _mock_response(data, status_code: int = 200, text: str = ""):+def _mock_response(data: object, status_code: int = 200, text: str = "") -> mock.Mock:response = mock.Mock()response.status_code = status_coderesponse.text = text@@ -58,7 +58,7 @@ def _mock_response(data, status_code: int = 200, text: str = ""):class TestNotionExtractorInitAndPublicMethods:- def test_init_with_explicit_token(self):+ def test_init_with_explicit_token(self) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -70,7 +70,7 @@ class TestNotionExtractorInitAndPublicMethods:assert extractor._notion_access_token == "token"- def test_init_uses_injected_token_loader(self):+ def test_init_uses_injected_token_loader(self) -> None:loader = mock.Mock(return_value="resolved-token")extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",@@ -84,7 +84,7 @@ class TestNotionExtractorInitAndPublicMethods:assert extractor._notion_access_token == "resolved-token"loader.assert_called_once_with()- def test_init_propagates_missing_token_from_loader(self):+ def test_init_propagates_missing_token_from_loader(self) -> None:loader = mock.Mock(side_effect=ValueError("Must specify `integration_token`"))with pytest.raises(ValueError, match="Must specify `integration_token`"):notion_extractor.NotionExtractor(@@ -96,7 +96,7 @@ class TestNotionExtractorInitAndPublicMethods:notion_token_loader=loader,)- def test_extract_updates_last_edited_and_loads_documents(self, monkeypatch: pytest.MonkeyPatch):+ def test_extract_updates_last_edited_and_loads_documents(self, monkeypatch: pytest.MonkeyPatch) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -117,7 +117,7 @@ class TestNotionExtractorInitAndPublicMethods:load_mock.assert_called_once_with("obj", "page")assert len(docs) == 1- def test_load_data_as_documents_page_database_and_invalid(self, monkeypatch: pytest.MonkeyPatch):+ def test_load_data_as_documents_page_database_and_invalid(self, monkeypatch: pytest.MonkeyPatch) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -140,7 +140,7 @@ class TestNotionExtractorInitAndPublicMethods:class TestNotionDatabase:- def test_get_notion_database_data_parses_property_types_and_pagination(self, mocker: MockerFixture):+ def test_get_notion_database_data_parses_property_types_and_pagination(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -159,9 +159,9 @@ class TestNotionDatabase:"multi_select": [{"name": "A"}, {"name": "B"}],},"title_prop": {"type": "title", "title": [{"plain_text": "Title"}]},- "empty_title": {"type": "title", "title": []},+ "empty_title": {"type": "title", "title": list[object]()},"rich": {"type": "rich_text", "rich_text": [{"plain_text": "RichText"}]},- "empty_rich": {"type": "rich_text", "rich_text": []},+ "empty_rich": {"type": "rich_text", "rich_text": list[object]()},"select_prop": {"type": "select", "select": {"name": "Selected"}},"empty_select": {"type": "select", "select": None},"status_prop": {"type": "status", "status": {"name": "Open"}},@@ -175,7 +175,7 @@ class TestNotionDatabase:"has_more": True,"next_cursor": "cursor-2",}- second_page = {"results": [], "has_more": False, "next_cursor": None}+ second_page = {"results": list[object](), "has_more": False, "next_cursor": None}mock_post = mocker.patch("httpx.post", side_effect=[_mock_response(first_page), _mock_response(second_page)])@@ -191,7 +191,7 @@ class TestNotionDatabase:assert "Row Page URL:https://notion.so/page-1" in contentassert mock_post.call_count == 2- def test_get_notion_database_data_joins_all_rich_text_segments(self, mocker: MockerFixture):+ def test_get_notion_database_data_joins_all_rich_text_segments(self, mocker: MockerFixture) -> None:"""Formatted text arrives as multiple segments; all of them must be kept."""extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",@@ -235,7 +235,7 @@ class TestNotionDatabase:assert "rich:first second third" in contentassert "title_prop:Hello world" in content- def test_get_notion_database_data_handles_missing_results_and_empty_content(self, mocker: MockerFixture):+ def test_get_notion_database_data_handles_missing_results_and_empty_content(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -248,7 +248,7 @@ class TestNotionDatabase:mocker.patch("httpx.post", return_value=_mock_response({"results": None}))assert extractor._get_notion_database_data("db-1") == []- def test_requests_use_bounded_timeout(self, mocker: MockerFixture):+ def test_requests_use_bounded_timeout(self, mocker: MockerFixture) -> None:"""All outbound Notion API calls must carry a bounded timeout so a hanging endpoint cannot block extraction."""extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",@@ -269,7 +269,7 @@ class TestNotionDatabase:extractor.get_notion_last_edited_time()assert mock_request.call_args.kwargs["timeout"] == notion_extractor._REQUEST_TIMEOUT- def test_get_notion_database_data_requires_access_token(self):+ def test_get_notion_database_data_requires_access_token(self) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -285,7 +285,9 @@ class TestNotionDatabase:class TestNotionBlocks:- def test_get_notion_block_data_success_with_table_headings_children_and_pagination(self, mocker: MockerFixture):+ def test_get_notion_block_data_success_with_table_headings_children_and_pagination(+ self, mocker: MockerFixture+ ) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -297,7 +299,7 @@ class TestNotionBlocks:first_response = {"results": [- {"type": "table", "id": "tbl-1", "has_children": False, "table": {}},+ {"type": "table", "id": "tbl-1", "has_children": False, "table": dict[str, object]()},{"type": "heading_1","id": "h1",@@ -314,7 +316,7 @@ class TestNotionBlocks:"type": "child_page","id": "cp1","has_children": True,- "child_page": {"rich_text": []},+ "child_page": {"rich_text": list[object]()},},],"next_cursor": "cursor-2",@@ -342,7 +344,7 @@ class TestNotionBlocks:assert "Paragraph\nCHILD\n\n" in lines[2]assert "## SubHeading" in lines[-1]- def test_get_notion_block_data_handles_http_error_and_invalid_payload(self, mocker: MockerFixture):+ def test_get_notion_block_data_handles_http_error_and_invalid_payload(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -364,7 +366,7 @@ class TestNotionBlocks:with pytest.raises(ValueError, match="Error fetching Notion block data: boom"):extractor._get_notion_block_data("page-1")- def test_read_block_supports_heading_table_and_recursion(self, mocker: MockerFixture):+ def test_read_block_supports_heading_table_and_recursion(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -388,7 +390,7 @@ class TestNotionBlocks:"has_children": True,"paragraph": {"rich_text": [{"text": {"content": "Parent"}}]},},- {"type": "table", "id": "tbl-1", "has_children": False, "table": {}},+ {"type": "table", "id": "tbl-1", "has_children": False, "table": dict[str, object]()},],"next_cursor": None,}@@ -414,7 +416,7 @@ class TestNotionBlocks:assert "Child" in contentassert "TABLE-MD" in content- def test_read_block_breaks_on_missing_results(self, mocker: MockerFixture):+ def test_read_block_breaks_on_missing_results(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -427,7 +429,7 @@ class TestNotionBlocks:assert extractor._read_block("root") == ""- def test_read_table_rows_formats_markdown_with_pagination(self, mocker: MockerFixture):+ def test_read_table_rows_formats_markdown_with_pagination(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -464,7 +466,7 @@ class TestNotionBlocks:"table_row": {"cells": [[{"text": {"content": "H1"}}],- [],+ list[object](),]}},@@ -489,7 +491,7 @@ class TestNotionBlocks:assert "| H1 | |" in markdownassert "| R2C1 | R2C2 |" in markdown- def test_read_table_rows_joins_rich_text_segments_within_cell(self, mocker: MockerFixture):+ def test_read_table_rows_joins_rich_text_segments_within_cell(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -532,7 +534,7 @@ class TestNotionBlocks:if line.startswith("|"):assert line.count("|") == 3- def test_read_table_rows_preserves_empty_data_cells_as_columns(self, mocker: MockerFixture):+ def test_read_table_rows_preserves_empty_data_cells_as_columns(self, mocker: MockerFixture) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -557,7 +559,7 @@ class TestNotionBlocks:"table_row": {"cells": [[{"text": {"content": "a1"}}],- [],+ list[object](),[{"text": {"content": "c1"}}],]}@@ -576,7 +578,7 @@ class TestNotionBlocks:class TestNotionMetadataAndCredentialMethods:- def test_update_last_edited_time_no_document_model(self):+ def test_update_last_edited_time_no_document_model(self) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -592,7 +594,7 @@ class TestNotionMetadataAndCredentialMethods:self,monkeypatch: pytest.MonkeyPatch,persisted_document: tuple[sessionmaker[Session], DocumentModel],- ):+ ) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -621,7 +623,7 @@ class TestNotionMetadataAndCredentialMethods:self,monkeypatch: pytest.MonkeyPatch,persisted_document: tuple[sessionmaker[Session], DocumentModel],- ):+ ) -> None:session_maker, document = persisted_documentextractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",@@ -639,7 +641,7 @@ class TestNotionMetadataAndCredentialMethods:assert stored is not Noneassert stored.data_source_info_dict["last_edited_time"] == "2025-01-01T00:00:00.000Z"- def test_get_notion_last_edited_time_uses_page_and_database_urls(self, mocker: MockerFixture):+ def test_get_notion_last_edited_time_uses_page_and_database_urls(self, mocker: MockerFixture) -> None:extractor_page = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="page-id",@@ -670,7 +672,7 @@ class TestNotionMetadataAndCredentialMethods:assert extractor_db.get_notion_last_edited_time() == "2025-06-01T00:00:00.000Z"assert "databases/db-id" in request_mock.call_args[0][1]- def test_get_notion_last_edited_time_requires_access_token(self):+ def test_get_notion_last_edited_time_requires_access_token(self) -> None:extractor = notion_extractor.NotionExtractor(notion_workspace_id="ws",notion_obj_id="obj",@@ -685,12 +687,12 @@ class TestNotionMetadataAndCredentialMethods:extractor.get_notion_last_edited_time()-def test_get_cell_text_uses_plain_text_for_mention_and_equation_segments():+def test_get_cell_text_uses_plain_text_for_mention_and_equation_segments() -> None:# Notion rich text segments of type mention or equation carry plain_text# but no "text" object; they must not be dropped from the cell content.cell = [{"type": "text", "text": {"content": "see "}, "plain_text": "see "},- {"type": "mention", "mention": {"type": "user", "user": {}}, "plain_text": "@alice"},+ {"type": "mention", "mention": {"type": "user", "user": dict[str, object]()}, "plain_text": "@alice"},{"type": "equation", "equation": {"expression": "e=mc^2"}, "plain_text": "e=mc^2"},]assert notion_extractor.NotionExtractor._get_cell_text(cell) == "see @alicee=mc^2"diff --git a/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_function_call_router.py b/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_function_call_router.pyindex 43c521dcfd4..8ef8e16b647 100644--- a/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_function_call_router.py+++ b/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_function_call_router.py@@ -62,7 +62,7 @@ class TestFunctionCallMultiDatasetRouter:router = FunctionCallMultiDatasetRouter()response = Mock()response.usage = LLMUsage.empty_usage()- response.message.tool_calls = []+ response.message.tool_calls = list[object]()model_instance = Mock()model_instance.invoke_llm.return_value = responsetool_1 = Mock()diff --git a/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.py b/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.pyindex bcc8ee8fcb5..562a49a4f11 100644--- a/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.py+++ b/api/tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.py@@ -1,3 +1,4 @@+from collections.abc import Generatorfrom types import SimpleNamespacefrom unittest.mock import Mock, patch@@ -191,7 +192,10 @@ class TestReactMultiDatasetRouter:delta = SimpleNamespace(message=SimpleNamespace(content="part"), usage=None)chunk = SimpleNamespace(model="m1", prompt_messages=[Mock()], delta=delta)- text, usage = router._handle_invoke_result(iter([chunk]))+ def stream() -> Generator[SimpleNamespace]:+ yield chunk++ text, usage = router._handle_invoke_result(stream())assert text == "part"assert usage == LLMUsage.empty_usage()@@ -229,7 +233,7 @@ class TestReactMultiDatasetRouter:router = ReactMultiDatasetRouter()model_config = Mock()model_config.mode = "unknown-mode"- model_config.parameters = {}+ model_config.parameters = dict[str, object]()tool = Mock()tool.name = "dataset-1"tool.description = "desc"diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex aec94de0e96..d7e43c75791 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -395,18 +395,14 @@ project-excludes = ["core/rag/datasource/keyword/jieba/test_jieba_keyword_table_handler.py","core/rag/datasource/test_datasource_retrieval.py","core/rag/datasource/vdb/test_vector_factory.py",- "core/rag/embedding/test_embedding_base.py","core/rag/embedding/test_embedding_service.py","core/rag/extractor/blob/test_blob.py","core/rag/extractor/test_csv_extractor.py","core/rag/extractor/test_excel_extractor.py","core/rag/extractor/test_extract_processor.py",- "core/rag/extractor/test_extractor_base.py","core/rag/extractor/test_helpers.py","core/rag/extractor/test_html_extractor.py",- "core/rag/extractor/test_jina_reader_extractor.py","core/rag/extractor/test_markdown_extractor.py",- "core/rag/extractor/test_notion_extractor.py","core/rag/extractor/test_word_extractor.py","core/rag/extractor/unstructured/test_unstructured_extractors.py","core/rag/extractor/watercrawl/test_watercrawl.py",@@ -417,8 +413,6 @@ project-excludes = ["core/rag/rerank/test_reranker.py","core/rag/retrieval/test_dataset_retrieval.py","core/rag/retrieval/test_dataset_retrieval_methods.py",- "core/rag/retrieval/test_multi_dataset_function_call_router.py",- "core/rag/retrieval/test_multi_dataset_react_route.py","core/rag/splitter/test_text_splitter.py","core/repositories/test_celery_workflow_execution_repository.py","core/repositories/test_celery_workflow_node_execution_repository.py",