refactor(api): tighten types in core/rag batch 1#34702
Open
tmimmanuel wants to merge 8 commits intolanggenius:mainfrom
Open
refactor(api): tighten types in core/rag batch 1#34702tmimmanuel wants to merge 8 commits intolanggenius:mainfrom
tmimmanuel wants to merge 8 commits intolanggenius:mainfrom
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 01:25:50.817740184 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 01:25:42.304722147 +0000
@@ -128,8 +128,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -235,8 +233,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
@@ -289,6 +285,8 @@
--> core/rag/index_processor/processor/qa_index_processor.py:205:16
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[SystemPromptMessage | UserPromptMessage], tools=list[PromptMessageTool], stream=Literal[False], model_parameters=dict[str, float | int]) [no-matching-overload]
--> core/rag/retrieval/router/multi_dataset_function_call_router.py:32:58
+ERROR Could not import `AbstractSet` from `collections.abc` [missing-module-attribute]
+ --> core/rag/splitter/text_splitter.py:7:29
ERROR Class member `MCPToolProviderController.entity` overrides parent class `ToolProviderController` in an inconsistent manner [bad-override]
--> core/tools/mcp_tool/provider.py:33:14
ERROR Class member `PluginToolProviderController.entity` overrides parent class `BuiltinToolProviderController` in an inconsistent manner [bad-override]
|
added 2 commits
April 8, 2026 06:46
auto-merge was automatically disabled
April 8, 2026 14:03
Head branch was pushed to by a user without write access
b2fe82c to
a03b2e4
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 14:04:38.831329157 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 14:04:29.191101261 +0000
@@ -128,8 +128,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -235,8 +233,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
@@ -4989,7 +4985,7 @@
ERROR Argument `Iterator[Any | Unknown] | Iterator[Any]` is not assignable to parameter `invoke_result` with type `Generator[Unknown]` in function `core.rag.retrieval.router.multi_dataset_react_route.ReactMultiDatasetRouter._handle_invoke_result` [bad-argument-type]
--> tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.py:199:52
ERROR Argument `None` is not assignable to parameter `text` with type `str` in function `core.rag.splitter.text_splitter.RecursiveCharacterTextSplitter.split_text` [bad-argument-type]
- --> tests/unit_tests/core/rag/splitter/test_text_splitter.py:1877:42
+ --> tests/unit_tests/core/rag/splitter/test_text_splitter.py:1854:42
ERROR Cannot instantiate `CeleryWorkflowNodeExecutionRepository` because the following members are abstract: `save_execution_data` [bad-instantiation]
--> tests/unit_tests/core/repositories/test_celery_workflow_node_execution_repository.py:80:53
ERROR Cannot instantiate `CeleryWorkflowNodeExecutionRepository` because the following members are abstract: `save_execution_data` [bad-instantiation]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 14:06:37.891665830 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 14:06:27.855617238 +0000
@@ -128,8 +128,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -235,8 +233,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
@@ -4989,7 +4985,7 @@
ERROR Argument `Iterator[Any | Unknown] | Iterator[Any]` is not assignable to parameter `invoke_result` with type `Generator[Unknown]` in function `core.rag.retrieval.router.multi_dataset_react_route.ReactMultiDatasetRouter._handle_invoke_result` [bad-argument-type]
--> tests/unit_tests/core/rag/retrieval/test_multi_dataset_react_route.py:199:52
ERROR Argument `None` is not assignable to parameter `text` with type `str` in function `core.rag.splitter.text_splitter.RecursiveCharacterTextSplitter.split_text` [bad-argument-type]
- --> tests/unit_tests/core/rag/splitter/test_text_splitter.py:1877:42
+ --> tests/unit_tests/core/rag/splitter/test_text_splitter.py:1854:42
ERROR Cannot instantiate `CeleryWorkflowNodeExecutionRepository` because the following members are abstract: `save_execution_data` [bad-instantiation]
--> tests/unit_tests/core/repositories/test_celery_workflow_node_execution_repository.py:80:53
ERROR Cannot instantiate `CeleryWorkflowNodeExecutionRepository` because the following members are abstract: `save_execution_data` [bad-instantiation]
|
Contributor
Author
|
@asukaminato0721 Please review this PR. |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors api/core/rag to reduce Pyright/Basedpyright findings by tightening type annotations and aligning some adapter/test code with updated contracts.
Changes:
- Adjust vector DB adapters/tests (Matrixone / Upstash / Huawei) to better match
BaseVectorcontracts and public APIs. - Simplify text splitter/tokenizer typing and remove unused/dead logic paths, with corresponding unit test updates.
- Update Pyright configuration to allow an untyped optional dependency (
iris).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| api/tests/unit_tests/core/rag/splitter/test_text_splitter.py | Updates splitter tests to match the new from_encoder behavior and removes frame-introspection. |
| api/tests/unit_tests/core/rag/datasource/vdb/matrixone/test_matrixone_vector.py | Updates tests to use the new public get_client accessor. |
| api/pyrightconfig.json | Adds iris to allowedUntypedLibraries. |
| api/core/rag/splitter/text_splitter.py | Tightens tokenizer option types (allowed_special / disallowed_special) and avoids mutable defaults. |
| api/core/rag/splitter/fixed_text_splitter.py | Removes token-counting encoder logic and keeps a character-length encoder. |
| api/core/rag/datasource/vdb/upstash/upstash_vector.py | Makes add_texts return ids and reworks vector id assignment. |
| api/core/rag/datasource/vdb/matrixone/matrixone_vector.py | Renames _get_client to get_client and updates the decorator/call sites accordingly. |
| api/core/rag/datasource/vdb/huawei/huawei_cloud_vector.py | Adds explicit type annotation for Elasticsearch params dict. |
| api/core/rag/datasource/retrieval_service.py | Removes an unused loop binding in as_completed iteration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
20d8fc3 to
d600001
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-09 03:13:12.944924875 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-09 03:13:03.879957468 +0000
@@ -126,8 +126,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -233,8 +231,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-09 03:15:26.627817722 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-09 03:15:17.336824107 +0000
@@ -126,8 +126,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -233,8 +231,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-09 03:54:18.915600965 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-09 03:54:09.474609842 +0000
@@ -126,8 +126,6 @@
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
ERROR Unpacked keyword argument `bool | Unknown | None` is not assignable to parameter `max_retries` with type `Decimal | bool | bytes | float | int | str` in function `ElasticSearchConfig.__init__` [bad-argument-type]
--> core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py:355:40
-ERROR `tuple[str, str]` is not assignable to TypedDict key `basic_auth` with type `bool | int | list[str]` [bad-typed-dict-key]
- --> core/rag/datasource/vdb/huawei/huawei_cloud_vector.py:51:36
ERROR Class member `LindormVectorStore.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/lindorm/lindorm_vector.py:84:9
ERROR `str | None` is not assignable to TypedDict key `routing` with type `str` [bad-typed-dict-key]
@@ -233,8 +231,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
|
Contributor
Author
|
@asukaminato0721 Can you review again please? |
3 tasks
…nto refactor/pyright-core-rag-pr1
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-10 17:46:16.582436777 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-10 17:46:07.598398443 +0000
@@ -245,8 +245,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
|
Contributor
Author
|
@asukaminato0721 |
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-13 03:07:05.403262669 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-13 03:06:56.443120694 +0000
@@ -245,8 +245,6 @@
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:71:20
ERROR `None` is not subscriptable [unsupported-operation]
--> core/rag/datasource/vdb/tidb_on_qdrant/tidb_service.py:72:35
-ERROR Class member `UpstashVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
- --> core/rag/datasource/vdb/upstash/upstash_vector.py:47:9
ERROR Class member `VikingDBVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
--> core/rag/datasource/vdb/vikingdb/vikingdb_vector.py:117:9
ERROR Object of class `list` has no attribute `fields` [missing-attribute]
|
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Author
|
Hi, @asukaminato0721 Sorry for interrupting you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor tracked in #26412: improve static typing for
api/core/ragby resolving Pyright/Basedpyright findings in the first batch, without changing intended runtime behavior.What changed
BaseVector(structured params typing, avoid private-member access from decorators via a public accessor, ensureadd_textsmatches the abstract return type).irisdependency in Pyright config (allowedUntypedLibraries) where stubs are not available.