Component
Core / Python SDK
Description
Two mutable default arguments in the Python SDK — the classic anti-pattern flagged by ruff B006 and pylint W0102. The same list/dict instance is shared across every call that uses the default, so any in-place mutation leaks across calls.
Affected symbols
mem0/proxy/main.py — Completions.create(messages: List = [])
mem0/configs/embeddings/base.py — BaseEmbedderConfig.__init__(azure_kwargs: Optional[AzureConfig] = {}) (also a type-annotation mismatch — declared Optional but defaulted to {})
Reproduction
import inspect
from mem0.proxy.main import Completions
sig = inspect.signature(Completions.create)
default = sig.parameters["messages"].default
print(type(default).__name__, id(default))
# list 0x... — a single module-level instance shared across every call
Expected behavior
Each call should receive its own fresh [] / {}, isolated from other calls.
Environment
N/A — code-quality bug, environment-independent (Python 3.10+ source).
Component
Core / Python SDK
Description
Two mutable default arguments in the Python SDK — the classic anti-pattern flagged by ruff B006 and pylint W0102. The same list/dict instance is shared across every call that uses the default, so any in-place mutation leaks across calls.
Affected symbols
mem0/proxy/main.py—Completions.create(messages: List = [])mem0/configs/embeddings/base.py—BaseEmbedderConfig.__init__(azure_kwargs: Optional[AzureConfig] = {})(also a type-annotation mismatch — declaredOptionalbut defaulted to{})Reproduction