Skip to content

refactor(api): fix pyright errors in jieba, milvus, couchbase, oracle, and router#34938

Open
tmimmanuel wants to merge 4 commits intolanggenius:mainfrom
tmimmanuel:refactor/pyright-core-rag-keyword-vdb-lint
Open

refactor(api): fix pyright errors in jieba, milvus, couchbase, oracle, and router#34938
tmimmanuel wants to merge 4 commits intolanggenius:mainfrom
tmimmanuel:refactor/pyright-core-rag-keyword-vdb-lint

Conversation

@tmimmanuel
Copy link
Copy Markdown
Contributor

Summary

  • Add null guard for dataset_keyword_table in jieba keyword handler
  • Cast untyped jieba cut() return and provide default for None topK
  • Suppress invoke_llm overload mismatch in multi-dataset function call router
  • Widen pool_params dict type in oracle vector to accept None values
  • Cast describe_collection and get_server_version returns in milvus vector
  • Suppress couchbase SDK type stub mismatches

Test plan

  • make type-check-core passes with 0 errors
  • All 237 affected unit tests pass (no test changes needed)
  • No runtime behavior changes — type annotations, casts, and null guards only

Part of #26412

@tmimmanuel tmimmanuel requested a review from JohnJyong as a code owner April 10, 2026 17:49
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 17:50:48.240180829 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 17:50:39.811213395 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._create_namespace_request.CreateNamespaceRequest.__init__` [bad-argument-type]
    --> core/rag/datasource/vdb/analyticdb/analyticdb_vector_openapi.py:120:40
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._describe_collection_request.DescribeCollectionRequest.__init__` [bad-argument-type]
@@ -158,10 +150,6 @@
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:398:33
 ERROR `None` is not subscriptable [unsupported-operation]
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:401:30
-ERROR Cannot index into `Coroutine[Unknown, Unknown, Unknown]` [bad-index]
-  --> core/rag/datasource/vdb/milvus/milvus_vector.py:96:50
-ERROR Argument `dict[Unknown, Unknown] | str` is not assignable to parameter `version` with type `str` in function `packaging.version.parse` [bad-argument-type]
-   --> core/rag/datasource/vdb/milvus/milvus_vector.py:114:34
 ERROR Argument `Literal['HNSW']` is not assignable to parameter `index_type` with type `VecIndexType` in function `pyobvector.client.index_param.IndexParams.add_index` [bad-argument-type]
    --> core/rag/datasource/vdb/oceanbase/oceanbase_vector.py:160:28
 ERROR Class member `OceanBaseVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
@@ -170,10 +158,8 @@
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:110:9
 ERROR `dict[str, dict[Field | str, list[float] | Any]]` is not assignable to TypedDict key with type `dict[Field, dict[Field | str, list[float] | Any]]` [bad-typed-dict-key]
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:204:33
-ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, str | None]) [no-matching-overload]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:139:31
 ERROR Function declared to return `bool`, but one or more paths are missing an explicit `return` [bad-return]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:191:39
+   --> core/rag/datasource/vdb/oracle/oraclevector.py:187:39
 ERROR No matching overload found for function `sqlalchemy.sql.sqltypes.UUID.__init__` called with arguments: (as_uuid=Literal[True]) [no-matching-overload]
   --> core/rag/datasource/vdb/pgvecto_rs/pgvecto_rs.py:66:32
 ERROR Argument `str | None` is not assignable to parameter `database_name` with type `str` in function `tcvectordb.rpc.client.stub.RPCVectorDBClient.describe_collection` [bad-argument-type]

@tmimmanuel tmimmanuel changed the title Refactor/pyright core rag keyword vdb lint refactor(api): fix pyright errors in jieba, milvus, couchbase, oracle, and router Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 18:08:21.819179476 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 18:08:12.381237744 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._create_namespace_request.CreateNamespaceRequest.__init__` [bad-argument-type]
    --> core/rag/datasource/vdb/analyticdb/analyticdb_vector_openapi.py:120:40
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._describe_collection_request.DescribeCollectionRequest.__init__` [bad-argument-type]
@@ -158,10 +150,6 @@
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:398:33
 ERROR `None` is not subscriptable [unsupported-operation]
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:401:30
-ERROR Cannot index into `Coroutine[Unknown, Unknown, Unknown]` [bad-index]
-  --> core/rag/datasource/vdb/milvus/milvus_vector.py:96:50
-ERROR Argument `dict[Unknown, Unknown] | str` is not assignable to parameter `version` with type `str` in function `packaging.version.parse` [bad-argument-type]
-   --> core/rag/datasource/vdb/milvus/milvus_vector.py:114:34
 ERROR Argument `Literal['HNSW']` is not assignable to parameter `index_type` with type `VecIndexType` in function `pyobvector.client.index_param.IndexParams.add_index` [bad-argument-type]
    --> core/rag/datasource/vdb/oceanbase/oceanbase_vector.py:160:28
 ERROR Class member `OceanBaseVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
@@ -170,10 +158,8 @@
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:110:9
 ERROR `dict[str, dict[Field | str, list[float] | Any]]` is not assignable to TypedDict key with type `dict[Field, dict[Field | str, list[float] | Any]]` [bad-typed-dict-key]
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:204:33
-ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, str | None]) [no-matching-overload]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:139:31
 ERROR Function declared to return `bool`, but one or more paths are missing an explicit `return` [bad-return]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:191:39
+   --> core/rag/datasource/vdb/oracle/oraclevector.py:187:39
 ERROR No matching overload found for function `sqlalchemy.sql.sqltypes.UUID.__init__` called with arguments: (as_uuid=Literal[True]) [no-matching-overload]
   --> core/rag/datasource/vdb/pgvecto_rs/pgvecto_rs.py:66:32
 ERROR Argument `str | None` is not assignable to parameter `database_name` with type `str` in function `tcvectordb.rpc.client.stub.RPCVectorDBClient.describe_collection` [bad-argument-type]

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Apr 10, 2026
Comment thread api/core/rag/datasource/vdb/oracle/oraclevector.py Outdated
Comment thread api/core/rag/datasource/vdb/milvus/milvus_vector.py Outdated
@tmimmanuel tmimmanuel force-pushed the refactor/pyright-core-rag-keyword-vdb-lint branch from 3aba995 to 1c5b97d Compare April 11, 2026 15:57
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-11 15:58:44.512731923 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-11 15:58:36.592546634 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._create_namespace_request.CreateNamespaceRequest.__init__` [bad-argument-type]
    --> core/rag/datasource/vdb/analyticdb/analyticdb_vector_openapi.py:120:40
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._describe_collection_request.DescribeCollectionRequest.__init__` [bad-argument-type]
@@ -158,10 +150,6 @@
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:398:33
 ERROR `None` is not subscriptable [unsupported-operation]
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:401:30
-ERROR Cannot index into `Coroutine[Unknown, Unknown, Unknown]` [bad-index]
-  --> core/rag/datasource/vdb/milvus/milvus_vector.py:96:50
-ERROR Argument `dict[Unknown, Unknown] | str` is not assignable to parameter `version` with type `str` in function `packaging.version.parse` [bad-argument-type]
-   --> core/rag/datasource/vdb/milvus/milvus_vector.py:114:34
 ERROR Argument `Literal['HNSW']` is not assignable to parameter `index_type` with type `VecIndexType` in function `pyobvector.client.index_param.IndexParams.add_index` [bad-argument-type]
    --> core/rag/datasource/vdb/oceanbase/oceanbase_vector.py:160:28
 ERROR Class member `OceanBaseVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
@@ -170,10 +158,8 @@
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:110:9
 ERROR `dict[str, dict[Field | str, list[float] | Any]]` is not assignable to TypedDict key with type `dict[Field, dict[Field | str, list[float] | Any]]` [bad-typed-dict-key]
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:204:33
-ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, str | None]) [no-matching-overload]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:139:31
 ERROR Function declared to return `bool`, but one or more paths are missing an explicit `return` [bad-return]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:191:39
+   --> core/rag/datasource/vdb/oracle/oraclevector.py:199:39
 ERROR No matching overload found for function `sqlalchemy.sql.sqltypes.UUID.__init__` called with arguments: (as_uuid=Literal[True]) [no-matching-overload]
   --> core/rag/datasource/vdb/pgvecto_rs/pgvecto_rs.py:66:32
 ERROR Argument `str | None` is not assignable to parameter `database_name` with type `str` in function `tcvectordb.rpc.client.stub.RPCVectorDBClient.describe_collection` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-13 03:06:43.039355202 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-13 03:06:34.573440896 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._create_namespace_request.CreateNamespaceRequest.__init__` [bad-argument-type]
    --> core/rag/datasource/vdb/analyticdb/analyticdb_vector_openapi.py:120:40
 ERROR Argument `str | None` is not assignable to parameter `namespace_password` with type `str` in function `alibabacloud_gpdb20160503.models._describe_collection_request.DescribeCollectionRequest.__init__` [bad-argument-type]
@@ -158,10 +150,6 @@
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:398:33
 ERROR `None` is not subscriptable [unsupported-operation]
    --> core/rag/datasource/vdb/lindorm/lindorm_vector.py:401:30
-ERROR Cannot index into `Coroutine[Unknown, Unknown, Unknown]` [bad-index]
-  --> core/rag/datasource/vdb/milvus/milvus_vector.py:96:50
-ERROR Argument `dict[Unknown, Unknown] | str` is not assignable to parameter `version` with type `str` in function `packaging.version.parse` [bad-argument-type]
-   --> core/rag/datasource/vdb/milvus/milvus_vector.py:114:34
 ERROR Argument `Literal['HNSW']` is not assignable to parameter `index_type` with type `VecIndexType` in function `pyobvector.client.index_param.IndexParams.add_index` [bad-argument-type]
    --> core/rag/datasource/vdb/oceanbase/oceanbase_vector.py:160:28
 ERROR Class member `OceanBaseVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
@@ -170,10 +158,8 @@
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:110:9
 ERROR `dict[str, dict[Field | str, list[float] | Any]]` is not assignable to TypedDict key with type `dict[Field, dict[Field | str, list[float] | Any]]` [bad-typed-dict-key]
    --> core/rag/datasource/vdb/opensearch/opensearch_vector.py:204:33
-ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, str | None]) [no-matching-overload]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:139:31
 ERROR Function declared to return `bool`, but one or more paths are missing an explicit `return` [bad-return]
-   --> core/rag/datasource/vdb/oracle/oraclevector.py:191:39
+   --> core/rag/datasource/vdb/oracle/oraclevector.py:199:39
 ERROR No matching overload found for function `sqlalchemy.sql.sqltypes.UUID.__init__` called with arguments: (as_uuid=Literal[True]) [no-matching-overload]
   --> core/rag/datasource/vdb/pgvecto_rs/pgvecto_rs.py:66:32
 ERROR Argument `str | None` is not assignable to parameter `database_name` with type `str` in function `tcvectordb.rpc.client.stub.RPCVectorDBClient.describe_collection` [bad-argument-type]

@tmimmanuel
Copy link
Copy Markdown
Contributor Author

Hi, @asukaminato0721
Sorry for interrupting. Could you review my PRs please. Thanks.

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-14 05:17:55.472870770 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-14 05:17:44.825842576 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR `upload_file` may be uninitialized [unbound-name]
    --> core/rag/extractor/extract_processor.py:116:61
 ERROR `upload_file` may be uninitialized [unbound-name]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-14 16:01:57.073380223 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-14 16:01:46.370367124 +0000
@@ -70,14 +70,6 @@
    --> core/ops/mlflow_trace/mlflow_trace.py:415:24
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
    --> core/ops/ops_trace_manager.py:206:9
-ERROR Object of class `NoneType` has no attribute `data_source_type` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:142:36
-ERROR Object of class `NoneType` has no attribute `keyword_table` [missing-attribute]
-   --> core/rag/datasource/keyword/jieba/jieba.py:144:13
-ERROR Cannot index into `set[Any]` [bad-index]
-   --> core/rag/datasource/keyword/jieba/jieba.py:157:29
-ERROR Argument `object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `list.__init__` [bad-argument-type]
-  --> core/rag/datasource/keyword/jieba/jieba_keyword_table_handler.py:88:35
 ERROR `upload_file` may be uninitialized [unbound-name]
    --> core/rag/extractor/extract_processor.py:116:61
 ERROR `upload_file` may be uninitialized [unbound-name]

@tmimmanuel
Copy link
Copy Markdown
Contributor Author

Hi, @asukaminato0721 @crazywoola
I fixed conflict problem. And I opened 3 more PRs (#34809 #34702 #34796).
Please review my PRs if you have time. Thank you. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants