Skip to content

Commit 7b57d59

Browse files
nagkumar91Copilot
andcommitted
fix: resolve pyright type check errors in LangChain callback handler
- Suppress reportUnknownArgumentType/reportUnknownVariableType on serialized_id list join (type comes from untyped dict[str, Any]) - Remove unnecessary isinstance(query, str) check — query param is already typed as str in on_retriever_start signature Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fc8390f commit 7b57d59

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

  • instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/callback_handler.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _resolve_retriever_store_id(
115115
return serialized_id
116116
if isinstance(serialized_id, list) and serialized_id:
117117
try:
118-
return ".".join(str(part) for part in serialized_id)
118+
return ".".join(str(part) for part in serialized_id) # type: ignore[reportUnknownArgumentType, reportUnknownVariableType]
119119
except TypeError:
120120
return None
121121
return None
@@ -398,11 +398,7 @@ def on_retriever_start(
398398
attributes[GEN_AI_MEMORY_STORE_NAME] = store_name
399399
if store_id := self._resolve_retriever_store_id(serialized, metadata):
400400
attributes[GEN_AI_MEMORY_STORE_ID] = store_id
401-
if (
402-
query
403-
and self._should_capture_memory_query()
404-
and isinstance(query, str)
405-
):
401+
if query and self._should_capture_memory_query():
406402
attributes[GEN_AI_MEMORY_QUERY] = query
407403
if metadata and metadata.get("memory_namespace"):
408404
attributes[GEN_AI_MEMORY_NAMESPACE] = metadata["memory_namespace"]

0 commit comments

Comments
 (0)