Skip to content

Commit dbbf383

Browse files
committed
fix: Resolve mypy unused-ignore error for optional langchain import
- Add mypy override to disable warn_unused_ignores for langchain integration module - Use placeholder class instead of None when langchain is not installed - This allows the code to pass mypy both with and without langchain installed The type: ignore comment is needed when langchain is NOT installed (CI), but triggers unused-ignore when it IS installed (local dev). The mypy override resolves this conflict.
1 parent 4fc4687 commit dbbf383

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

agent-memory-client/agent_memory_client/integrations/langchain.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@
4646
from agent_memory_client import MemoryAPIClient
4747

4848
try:
49-
from langchain_core.tools import StructuredTool
49+
from langchain_core.tools import StructuredTool # type: ignore # noqa: F401
5050

5151
LANGCHAIN_AVAILABLE = True
5252
except ImportError:
5353
LANGCHAIN_AVAILABLE = False
54-
StructuredTool = None # type: ignore[misc,assignment]
54+
55+
class StructuredTool: # type: ignore[no-redef]
56+
"""Placeholder for when LangChain is not installed."""
57+
58+
pass
5559

5660

5761
def _check_langchain_available() -> None:

agent-memory-client/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,7 @@ strict_equality = true
100100
[[tool.mypy.overrides]]
101101
module = "tests.*"
102102
disallow_untyped_defs = false
103+
104+
[[tool.mypy.overrides]]
105+
module = "agent_memory_client.integrations.langchain"
106+
warn_unused_ignores = false

0 commit comments

Comments
 (0)