feat: add ManagedBy StrEnum for managed_by parameter#1807
Merged
Conversation
Define a common ManagedBy StrEnum in connectorkits/target.py and use it across all 6 target connectors instead of scattered Literal["system", "user"] annotations. This gives a single source of truth, better IDE support, and clearer semantics. Also fixes pre-existing mypy errors in the SQLite target test by adding a type annotation and using the new enum. Closes cocoindex-io#1806 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
hold on, let me fix this, because its setting up the enum in statediff, which is confusing. |
Since ManagedBy lives in connectorkits/target.py, connectors should import it from there (target.ManagedBy) rather than going through statediff. This makes the provenance clear. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
ok @georgeh0 @badmonster0 for your review :) cc @prabhath004 |
georgeh0
approved these changes
Apr 5, 2026
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
ManagedByStrEnum inpython/cocoindex/connectorkits/target.pywithSYSTEMandUSERmembersLiteral["system", "user"]across 6 target connectors (postgres, sqlite, lancedb, doris, qdrant, surrealdb) withtarget.ManagedBystatediff.pyimportsManagedByfromtarget.pyfor its own internal use (MutualTrackingRecord,resolve_system_transition) and keeps it in__all__as a safety net, though no external code currently accessesManagedBythroughstatedifftest_sqlite_target.pyMotivation
Scattered
Literal["system", "user"]annotations made it easy to introduce typos and provided no IDE autocompletion. A singleStrEnumgives a canonical source of truth and better developer experience. SinceStrEnuminherits fromstr, this is fully backward compatible — existing string comparisons and serialization continue to work.Closes #1806
Test plan
uv run mypy— 0 errors (was 7 on base v1, 2 of which are also fixed here)uv run pytest python/— 495 passed, 70 skippedprek run --all-files— all 14 checks pass🤖 Generated with Claude Code