-
Notifications
You must be signed in to change notification settings - Fork 115
Private types exposed in public method signatures #1994
Description
Context
PR #1993 fixed this problem for _Filters by re-exporting the existing FilterReturn
alias from weaviate.classes.query. The same issue exists for many other private types
that appear in public method signatures across the client.
In pyright strict mode (reportPrivateUsage: error), any user code that needs to
type-annotate these parameters has to import private types, which is flagged as an
error.
Affected types
Collection creation (collections/executor.py — create())
| Parameter | Current type |
|---|---|
generative_config |
Optional[_GenerativeProvider] |
reranker_config |
Optional[_RerankerProvider] |
sharding_config |
Optional[_ShardingConfigCreate] |
inverted_index_config |
Optional[_InvertedIndexConfigCreate] |
multi_tenancy_config |
Optional[_MultiTenancyConfigCreate] |
object_ttl_config |
Optional[_ObjectTTLConfigCreate] |
replication_config |
Optional[_ReplicationConfigCreate] |
vector_index_config |
Optional[_VectorIndexConfigCreate] |
vectorizer_config |
Optional[Union[_VectorizerConfigCreate, List[_NamedVectorConfigCreate]]] |
vector_config |
Optional[Union[_VectorConfigCreate, List[_VectorConfigCreate]]] |
references |
Optional[List[_ReferencePropertyBase]] |
Collection config update (config/executor.py — update())
| Parameter | Current type |
|---|---|
generative_config |
Optional[_GenerativeProvider] |
reranker_config |
Optional[_RerankerProvider] |
inverted_index_config |
Optional[_InvertedIndexConfigUpdate] |
multi_tenancy_config |
Optional[_MultiTenancyConfigUpdate] |
object_ttl_config |
Optional[_ObjectTTLConfigUpdate] |
replication_config |
Optional[_ReplicationConfigUpdate] |
vector_index_config |
Optional[Union[_VectorIndexConfigHNSWUpdate, ...]] |
vectorizer_config |
Optional[Union[..., List[_NamedVectorConfigUpdate]]] |
vector_config |
Optional[Union[_VectorConfigUpdate, List[_VectorConfigUpdate]]] |
Collection config — other methods (config/executor.py)
| Method | Parameter | Current type |
|---|---|---|
add_reference() |
ref |
Union[ReferenceProperty, _ReferencePropertyMultiTarget] |
add_vector() |
vector_config |
Union[_NamedVectorConfigCreate, _VectorConfigCreate, ...] |
Generative queries (all 9 queries/*/generate/executor.py)
| Parameter | Current type |
|---|---|
single_prompt |
Union[str, _SinglePrompt, None] |
grouped_task |
Union[str, _GroupedTask, None] |
generative_provider |
Optional[_GenerativeConfigRuntime] |
Proposed solution
Follow the same pattern as #1993:
- Create public
TypeAliasentries in the source modules (drop the_prefix):
# config.py
GenerativeProvider = _GenerativeProvider
RerankerProvider = _RerankerProvider
ShardingConfigCreate = _ShardingConfigCreate
InvertedIndexConfigCreate = _InvertedIndexConfigCreate
InvertedIndexConfigUpdate = _InvertedIndexConfigUpdate
MultiTenancyConfigCreate = _MultiTenancyConfigCreate
MultiTenancyConfigUpdate = _MultiTenancyConfigUpdate
ReplicationConfigCreate = _ReplicationConfigCreate
ReplicationConfigUpdate = _ReplicationConfigUpdate
ReferencePropertyMultiTarget = _ReferencePropertyMultiTarget
# config_object_ttl.py
ObjectTTLConfigCreate = _ObjectTTLConfigCreate
ObjectTTLConfigUpdate = _ObjectTTLConfigUpdate
# config_vector_index.py
VectorIndexConfigCreate = _VectorIndexConfigCreate
VectorIndexConfigHNSWUpdate = _VectorIndexConfigHNSWUpdate
VectorIndexConfigFlatUpdate = _VectorIndexConfigFlatUpdate
VectorIndexConfigDynamicUpdate = _VectorIndexConfigDynamicUpdate
VectorIndexConfigHFreshUpdate = _VectorIndexConfigHFreshUpdate
# config_named_vectors.py
NamedVectorConfigCreate = _NamedVectorConfigCreate
NamedVectorConfigUpdate = _NamedVectorConfigUpdate
# config_vectorizers.py
VectorizerConfigCreate = _VectorizerConfigCreate
# config_vectors.py
VectorConfigCreate = _VectorConfigCreate
VectorConfigUpdate = _VectorConfigUpdateThree aliases already exist in generative.py but are not re-exported:
GenerativeConfigRuntime = _GenerativeConfigRuntime # line 53
GroupedTask = _GroupedTask # line 1252
SinglePrompt = _SinglePrompt # line 1253-
Replace private types with their public aliases in all executor files, so the
auto-generated stubs (viatools/stubs_regen.sh) expose public types. -
Re-export from
weaviate/classes/config.pyandweaviate/classes/generate.py.
Naming convention
Simply drop the _ prefix, consistent with the existing aliases (FilterReturn,
GenerativeConfigRuntime, GroupedTask, SinglePrompt).
Open to discussion if a different convention is preferred.
Implementation plan
Happy to submit the implementation. Given the number of types involved, splitting into
2-3 PRs grouped by domain seems reasonable:
- PR 1 — Config create types: types used in
collection.create()signatures - PR 2 — Config update types: types used in
collection.config.update()and related
methods - PR 3 — Generative types:
GenerativeConfigRuntime,GroupedTask,
SinglePrompt(aliases exist, just need re-export + executor rename)
Or a single PR if that's preferred — the changes are mechanical (same pattern as #1993).