Skip to content

Add type hints and docstrings to VectorStoreBase and EmbeddingBase#4629

Open
GopalGB wants to merge 1 commit intomem0ai:mainfrom
GopalGB:add-type-hints-vector-store-base
Open

Add type hints and docstrings to VectorStoreBase and EmbeddingBase#4629
GopalGB wants to merge 1 commit intomem0ai:mainfrom
GopalGB:add-type-hints-vector-store-base

Conversation

@GopalGB
Copy link
Copy Markdown
Contributor

@GopalGB GopalGB commented Mar 31, 2026

Summary

  • Add comprehensive type annotations to all 11 abstract methods in VectorStoreBase
  • Add detailed parameter and return type docstrings following Google style
  • Add missing default value for memory_action parameter in EmbeddingBase.embed()
  • Fix typo in reset() docstring ("delete" -> "deleting")

Motivation

The VectorStoreBase abstract class had no type hints on any of its method signatures, while concrete implementations (e.g., Qdrant, Chroma) already use typed parameters. This creates a gap where:

  • IDEs cannot provide autocompletion when coding against the base class
  • Static type checkers (mypy, pyright) cannot verify implementations match the contract
  • New contributors implementing custom vector stores have to read concrete implementations to understand expected types

Changes

mem0/vector_stores/base.py:

  • Added typing imports (Any, Dict, List, Optional, Union)
  • Annotated all parameters and return types across 11 abstract methods
  • Added Google-style docstrings with Args/Returns sections

mem0/embeddings/base.py:

  • Added return type -> list to embed() method
  • Added default = None for memory_action parameter (matching all implementations)
  • Cleaned up docstring formatting

Test plan

  • Verify existing tests pass (no behavioral changes, only annotations)
  • Confirm type annotations match concrete implementations (Qdrant, Chroma, Pinecone, etc.)

- Add comprehensive type annotations to all abstract methods in VectorStoreBase
- Add parameter and return type docstrings following Google style
- Add missing default value for memory_action parameter in EmbeddingBase.embed()
- Fix typo in reset() docstring ("delete" -> "deleting")
- Import typing constructs (Any, Dict, List, Optional, Union)

This improves IDE autocompletion, static analysis, and developer
experience when implementing custom vector store backends.
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.

1 participant