Skip to content

feat: export private collection config types as public aliases - #2049

Merged
g-despot merged 9 commits into
weaviate:mainfrom
LijuanTang94:fix/export-private-types-as-public
Sep 10, 2026
Merged

feat: export private collection config types as public aliases#2049
g-despot merged 9 commits into
weaviate:mainfrom
LijuanTang94:fix/export-private-types-as-public

Conversation

@LijuanTang94

@LijuanTang94 LijuanTang94 commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1994

Users who want to type-annotate parameters like generative_config, reranker_config, or vector_index_config in collection.create() and collection.config.update() currently have to import private _-prefixed types. Under pyright strict (reportPrivateUsage: error) that is an error.

This PR adds public TypeAlias entries for every private type in both tables of #1994, re-exports them from weaviate.classes.config, switches the executor signatures to the public names, and regenerates the sync.pyi / async_.pyi stubs — the same shape as #1993 did for FilterReturn.

23 new public exports (26 after the follow-up below; struck rows were dropped, see below):

create side update side
GenerativeProvider InvertedIndexConfigUpdate
InvertedIndexConfigCreate MultiTenancyConfigUpdate
MultiTenancyConfigCreate NamedVectorConfigUpdate
NamedVectorConfigCreate ObjectTTLConfigUpdate
ObjectTTLConfigCreate NamedVectorConfigUpdate
ReferencePropertyBase VectorConfigUpdate
ReferencePropertyMultiTarget VectorIndexConfigDynamicUpdate
ReplicationConfigCreate VectorIndexConfigFlatUpdate
RerankerProvider VectorIndexConfigHFreshUpdate
ShardingConfigCreate VectorIndexConfigHNSWUpdate
VectorConfigCreate
VectorIndexConfigCreate
VectorizerConfigCreate

Before

# pyright error: reportPrivateUsage
from weaviate.collections.classes.config import _GenerativeProvider

def my_helper(gen: Optional[_GenerativeProvider]) -> ...:
    ...

After

from weaviate.classes.config import GenerativeProvider

def my_helper(gen: Optional[GenerativeProvider]) -> ...:
    ...

Result

No private config type remains in any published stub — _GenerativeProvider, _RerankerProvider, _ReferencePropertyBase, _VectorizerConfigCreate, _NamedVectorConfigCreate, _VectorConfigCreate, _InvertedIndexConfigUpdate and _ReplicationConfigUpdate all now appear in 0 .pyi files. The signatures read:

generative_config: Optional[GenerativeProvider] = None,
references: Optional[List[ReferencePropertyBase]] = None,
inverted_index_config: Optional[InvertedIndexConfigUpdate] = None,
replication_config: Optional[ReplicationConfigUpdate] = None,

Testing

ruff check / ruff format --check   clean
pyright 1.1.399 (weaviate/)        0 errors
pytest test mock_tests             490 passed, 1 skipped

Annotating every create() argument in a standalone file under pyright strict with reportPrivateUsage: 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_input error text, repr/__name__, IDE hovers, and Sphinx, which showed each alias as a bare alias of _X with no fields. Flipped for 29 names; _X: TypeAlias = X shims 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 VectorIndexConfigUpdate and the 5 VectorIndexConfig*Create leaves.

  • 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.

  • boost uses the public BoostReturn instead of _Boost in the 14 query executors. BoostReturn already existed and was already exported from weaviate.classes.query.

  • Correction to "nothing removed": 54 private names are no longer re-exported incidentally from executor module namespaces (plus 14 more from the _Boost swap). 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, NamedVectorConfigCreate and NamedVectorConfigUpdate annotate nothing but deprecated paths — vectorizer_config emits Dep024/Dep023 and the named-vector add_vector overload is @deprecated, and both warnings point at vector_config instead. They stay private so the signature reads as the discouragement it should:

    vectorizer_config: Optional[Union[_VectorizerConfigCreate, List[_NamedVectorConfigCreate]]]  # deprecated
    vector_config:     Optional[Union[VectorConfigCreate, List[VectorConfigCreate]]]             # use this
  • Changelog entry added for 4.24.0.

Out of scope: the factory boundary — Configure.VectorIndex.hnsw() still takes quantizer: 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_tests 506 passed / 1 skipped, ruff + flake8 clean, stub regeneration idempotent. 26 public exports.

🤖 Generated with Claude Code

https://claude.ai/code/session_018mG6vBbjJfEVxaH95bwnVh

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

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.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@LijuanTang94

Copy link
Copy Markdown
Contributor Author

I have read the CLA and agree to the terms.

@LijuanTang94

Copy link
Copy Markdown
Contributor Author

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
@LijuanTang94
LijuanTang94 force-pushed the fix/export-private-types-as-public branch from 9929051 to 27e29d0 Compare August 14, 2026 18:47
@LijuanTang94

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (was 93 commits behind) — no conflicts, diff unchanged from the original.

Same CI situation as #2050: the Main workflow has never run here either — it's stuck at action_required pending first-time-contributor approval, so only the security scans show. Approving the run would make the real checks visible.

Locally against current main: 415 passed on main, 415 on this branch — no regression, as expected for a pure re-export. All 8 private types still exist under those names on main, and all 8 aliases resolve and land in weaviate.classes.config.__all__. ruff format --check is clean.

On the change: #1994 is still open, and this follows the same pattern as #1993 (FilterReturn) — TypeAlias entries so users running pyright in strict mode don't have to import _-prefixed types just to annotate collection.create() arguments.

@dirkkul

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 TypeAlias entries.
  • 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.

Comment thread weaviate/collections/classes/config.py Outdated
Comment on lines +3245 to +3250
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`.
@LijuanTang94

Copy link
Copy Markdown
Contributor Author

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 create() arguments and I had only covered eight. 5167bbe adds the four that were missing:

Public alias Private type create() argument
ReferencePropertyCreate _ReferencePropertyBase references
VectorizerConfigCreate _VectorizerConfigCreate vectorizer_config
NamedVectorConfigCreate _NamedVectorConfigCreate vectorizer_config
VectorConfigCreate _VectorConfigCreate vector_config

To confirm the aliases actually solve the reported problem, I annotated all eleven create() arguments in a standalone file under pyright strict with reportPrivateUsage: error: 12 errors using the private names, 0 using the aliases.

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 __all__ re-export it swapped _FiltersFilterReturn in every executor and regenerated all the .pyi stubs, ~60 files.

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:

  1. switch the collections/collections/executor.py annotations to the public names and regenerate sync.pyi / async_.pyi;
  2. the second table in Private types exposed in public method signatures #1994 — the whole collection.config.update() path (_InvertedIndexConfigUpdate, _MultiTenancyConfigUpdate, _ObjectTTLConfigUpdate, _ReplicationConfigUpdate, _VectorIndexConfig*Update, _NamedVectorConfigUpdate, _VectorConfigUpdate), which is equally in scope for the issue.

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 action_required, so only the security scans have ever run on this branch. You approved the run on #2050 — could you do the same here? Locally against current main:

ruff check / ruff format --check   clean
flake8                             clean
pyright 1.1.399 (weaviate/)        0 errors
pytest test/                       434 passed on main, 434 on this branch

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.
@g-despot

g-despot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

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.

LijuanTang94 and others added 5 commits September 8, 2026 16:29
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +5 to +7
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.
@g-despot
g-despot merged commit 5080bcf into weaviate:main Sep 10, 2026
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private types exposed in public method signatures

4 participants