feat: export private collection config types as public aliases - #2049
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge. |
|
I have read the CLA and agree to the terms. |
|
Hi team — just checking in on this PR. CLA is now signed and all checks are passing. Happy to make any changes if needed! |
Users annotating parameters like `generative_config`, `reranker_config`, `vector_index_config`, etc. had to import private `_`-prefixed types, which pyright strict mode (`reportPrivateUsage: error`) flags as an error. Adds public TypeAlias entries for the 8 affected types, following the same pattern as `FilterReturn` introduced in weaviate#1993: - GenerativeConfigCreate (_GenerativeProvider) - InvertedIndexConfigCreate (_InvertedIndexConfigCreate) - MultiTenancyConfigCreate (_MultiTenancyConfigCreate) - ObjectTTLConfigCreate (_ObjectTTLConfigCreate) - ReplicationConfigCreate (_ReplicationConfigCreate) - RerankerConfigCreate (_RerankerProvider) - ShardingConfigCreate (_ShardingConfigCreate) - VectorIndexConfigCreate (_VectorIndexConfigCreate) All 8 aliases are exported from `weaviate.classes.config`. Closes weaviate#1994
9929051 to
27e29d0
Compare
|
Rebased onto current Same CI situation as #2050: the Locally against current On the change: #1994 is still open, and this follows the same pattern as #1993 ( |
There was a problem hiding this comment.
🟡 Changes recommended
Public signatures remain private and several creation types covered by #1994 are omitted.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds public aliases for collection creation configuration types to avoid private imports.
Changes:
- Defines eight public
TypeAliasentries. - Re-exports them through
weaviate.classes.config.
File summaries
| File | Description |
|---|---|
weaviate/collections/classes/config.py |
Defines six configuration aliases. |
weaviate/collections/classes/config_object_ttl.py |
Defines the object TTL alias. |
weaviate/collections/classes/config_vector_index.py |
Defines the vector index alias. |
weaviate/classes/config.py |
Exposes all eight aliases publicly. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| GenerativeConfigCreate: TypeAlias = _GenerativeProvider | ||
| InvertedIndexConfigCreate: TypeAlias = _InvertedIndexConfigCreate | ||
| MultiTenancyConfigCreate: TypeAlias = _MultiTenancyConfigCreate | ||
| ReplicationConfigCreate: TypeAlias = _ReplicationConfigCreate | ||
| RerankerConfigCreate: TypeAlias = _RerankerProvider | ||
| ShardingConfigCreate: TypeAlias = _ShardingConfigCreate |
| ) | ||
|
|
||
|
|
||
| VectorIndexConfigCreate: TypeAlias = _VectorIndexConfigCreate |
Address Copilot review: the first table in weaviate#1994 lists eleven `collection.create()` arguments, but this branch only covered eight. Add the four missing aliases so every argument in that table can be annotated with a public name: ReferencePropertyCreate -> _ReferencePropertyBase VectorizerConfigCreate -> _VectorizerConfigCreate NamedVectorConfigCreate -> _NamedVectorConfigCreate VectorConfigCreate -> _VectorConfigCreate All four are re-exported from `weaviate.classes.config`.
|
Thanks for the review. Both of Copilot's points are correct — I've fixed the second and scoped the PR to match on the first. Missing aliases. Right: the first table in #1994 lists eleven
To confirm the aliases actually solve the reported problem, I annotated all eleven Signatures still expose the private names. Also correct, and I've updated the PR description to say "Part of #1994" rather than "Closes". Re-reading #1993, it does go further than this PR: alongside the I've kept this one to the alias export because it's independently useful and easy to review, and listed the remainder in the description as follow-ups:
Happy to fold either or both into this PR if you'd rather land it as a single change — just let me know before I touch ~60 files. One ask: CI here is still sitting at Unchanged test count, as expected for a pure re-export. |
…xecutor signatures Renames from review: GenerativeProvider, RerankerProvider, ReferencePropertyBase. Adds the update()-side aliases and ReferencePropertyMultiTarget, switches create/update/add_reference and the generate executors to the public names, and regenerates the stubs.
|
Thanks a lot for taking care of the comments, I have created a PR on top of yours that contains three minor renames and usage of the new names in method signatures. |
Complete weaviate#1994: update-side aliases and public names in executor signatures
The `BoostReturn` alias and its export from `weaviate.classes.query` already existed, and the `Boost` factory already returns and accepts it, but the query executors still annotated `boost` with the private `_Boost`. Users copying the name from a signature, hover, or stub hit `reportPrivateUsage` under strict type checking. Swaps the 14 query executors to `BoostReturn` and regenerates the stubs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh
The public names added for the collection config types were aliases to the private classes. An alias is transparent, so the private name stayed authoritative everywhere it is rendered: `_validate_input` errors, `__name__` and `repr`, IDE hovers, and Sphinx, which showed each one as a bare `alias of _X` with no fields. Flips the direction for 29 names: the class carries the public name and `_X: TypeAlias = X` shims keep the old spellings importable. Also exports the missing half of each vector index family, so the create and update sides are symmetric, and adds the 4.24.0 changelog entry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh
Conflicts in `Configure.replication` and `Reconfigure.replication`: main added the `async_enabled` deprecation warning while this branch renamed the returned class to its public name. Kept both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh
`VectorizerConfigCreate`, `NamedVectorConfigCreate` and `NamedVectorConfigUpdate` annotate nothing but deprecated paths: `vectorizer_config` on create and update emits Dep024/Dep023, the `add_vector` overload taking a named-vector config is `@deprecated`, and both warnings point at `vector_config` instead. A public name for them would advertise the path we are retiring. Drops them from `weaviate.classes.config.__all__` and returns the classes to their private spelling, so the deprecated arguments read `_VectorizerConfigCreate` next to a public `vector_config: VectorConfigCreate`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh
There was a problem hiding this comment.
🟡 Changes recommended
The new generative annotation types remain absent from the intended public generate namespace, and the export surface lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (3)
weaviate/collections/classes/config.py:3143
- Use “a” before the newly public class name: “VectorIndexConfigHFreshUpdate” begins with a consonant sound.
"""Create an `VectorIndexConfigHFreshUpdate` object to update the configuration of the HFresh vector index.
weaviate/collections/classes/config.py:3103
- Use “a” before the newly public class name: “VectorIndexConfigFlatUpdate” begins with a consonant sound.
"""Create an `VectorIndexConfigFlatUpdate` object to update the configuration of the FLAT vector index.
weaviate/collections/classes/config.py:3123
- Use “a” before the newly public class name: “VectorIndexConfigDynamicUpdate” begins with a consonant sound.
"""Create an `VectorIndexConfigDynamicUpdate` object to update the configuration of the Dynamic vector index.
- Files reviewed: 62/62 changed files
- Comments generated: 3
- Review effort level: Balanced
| GenerativeConfigRuntime, | ||
| GroupedTask, | ||
| SinglePrompt, |
| "ConsistencyLevel", | ||
| "Reconfigure", | ||
| "DataType", | ||
| "GenerativeProvider", |
| ) -> _VectorIndexConfigHNSWUpdate: | ||
| """Create an `_VectorIndexConfigHNSWUpdate` object to update the configuration of the HNSW vector index. | ||
| ) -> VectorIndexConfigHNSWUpdate: | ||
| """Create an `VectorIndexConfigHNSWUpdate` object to update the configuration of the HNSW vector index. |
Summary
Closes #1994
Users who want to type-annotate parameters like
generative_config,reranker_config, orvector_index_configincollection.create()andcollection.config.update()currently have to import private_-prefixed types. Under pyright strict (reportPrivateUsage: error) that is an error.This PR adds public
TypeAliasentries for every private type in both tables of #1994, re-exports them fromweaviate.classes.config, switches the executor signatures to the public names, and regenerates thesync.pyi/async_.pyistubs — the same shape as #1993 did forFilterReturn.23 new public exports (26 after the follow-up below;
struckrows were dropped, see below):GenerativeProviderInvertedIndexConfigUpdateInvertedIndexConfigCreateMultiTenancyConfigUpdateMultiTenancyConfigCreateNamedVectorConfigUpdateNamedVectorConfigCreateObjectTTLConfigUpdateObjectTTLConfigCreateNamedVectorConfigUpdateReferencePropertyBaseVectorConfigUpdateReferencePropertyMultiTargetVectorIndexConfigDynamicUpdateReplicationConfigCreateVectorIndexConfigFlatUpdateRerankerProviderVectorIndexConfigHFreshUpdateShardingConfigCreateVectorIndexConfigHNSWUpdateVectorConfigCreateVectorIndexConfigCreateVectorizerConfigCreateBefore
After
Result
No private config type remains in any published stub —
_GenerativeProvider,_RerankerProvider,_ReferencePropertyBase,_VectorizerConfigCreate,_NamedVectorConfigCreate,_VectorConfigCreate,_InvertedIndexConfigUpdateand_ReplicationConfigUpdateall now appear in 0.pyifiles. The signatures read:Testing
Annotating every
create()argument in a standalone file under pyright strict withreportPrivateUsage: error: 12 errors using the private names, 0 using the aliases.Credit
The update-side aliases, the three renames (
GenerativeProvider,RerankerProvider,ReferencePropertyBase), the executor signature switch and the stub regeneration come from @g-despot's follow-up branch, merged into this one.Follow-up changes
Pushed on top of the above, plus a merge of
main:The public name is now the class, not an alias to it. An alias is transparent, so the private name stayed authoritative wherever it is actually rendered —
_validate_inputerror text,repr/__name__, IDE hovers, and Sphinx, which showed each alias as a barealias of _Xwith no fields. Flipped for 29 names;_X: TypeAlias = Xshims keep every old spelling importable and identical.Create/update symmetry. The table above exports the create base with none of its 5 leaves, and 4 update leaves with no base. Added
VectorIndexConfigUpdateand the 5VectorIndexConfig*Createleaves.All 23 are now reachable from
weaviate.collections.classes.config, which previously re-exported the private counterparts of 12 of them and none of the public names.boostuses the publicBoostReturninstead of_Boostin the 14 query executors.BoostReturnalready existed and was already exported fromweaviate.classes.query.Correction to "nothing removed": 54 private names are no longer re-exported incidentally from executor module namespaces (plus 14 more from the
_Boostswap). Checked all 290 importable modules — no private name became unimportable, every one keeps its defining module, and nothing in this repo imported the dropped spellings.The three deprecated-path names are not exported.
VectorizerConfigCreate,NamedVectorConfigCreateandNamedVectorConfigUpdateannotate nothing but deprecated paths —vectorizer_configemits Dep024/Dep023 and the named-vectoradd_vectoroverload is@deprecated, and both warnings point atvector_configinstead. They stay private so the signature reads as the discouragement it should:Changelog entry added for 4.24.0.
Out of scope: the factory boundary —
Configure.VectorIndex.hnsw()still takesquantizer: Optional[_QuantizerConfigCreate]. Every normal way of building a quantizer (inline, bound to a variable, a dict of presets, a helper with no return annotation) type-checks clean under strict, so this only bites on an explicit annotation. Worth its own PR.Still missing: a test for the import surface. A rebind typo would type-check, pass every test and stub regen, and ship.
On the merged head: pyright 1.1.399 0 errors,
pytest test mock_tests506 passed / 1 skipped, ruff + flake8 clean, stub regeneration idempotent. 26 public exports.🤖 Generated with Claude Code
https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh