From 1c13ad95a574f4c701d7d27c9619816bb0145373 Mon Sep 17 00:00:00 2001 From: James Hush Date: Fri, 16 Jan 2026 14:38:05 +0800 Subject: [PATCH] Fix Pylance reportOptionalMemberAccess in _handle_function_call_cancel Extract dictionary value to local variable and check for None before accessing cancel_on_interruption attribute, since the dictionary values are typed as Optional[FunctionCallInProgressFrame]. --- src/pipecat/processors/aggregators/llm_response.py | 6 ++---- .../processors/aggregators/llm_response_universal.py | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pipecat/processors/aggregators/llm_response.py b/src/pipecat/processors/aggregators/llm_response.py index 81a92800a..1b53e9934 100644 --- a/src/pipecat/processors/aggregators/llm_response.py +++ b/src/pipecat/processors/aggregators/llm_response.py @@ -1024,10 +1024,8 @@ class LLMAssistantContextAggregator(LLMContextResponseAggregator): logger.debug( f"{self} FunctionCallCancelFrame: [{frame.function_name}:{frame.tool_call_id}]" ) - if frame.tool_call_id not in self._function_calls_in_progress: - return - - if self._function_calls_in_progress[frame.tool_call_id].cancel_on_interruption: + function_call = self._function_calls_in_progress.get(frame.tool_call_id) + if function_call and function_call.cancel_on_interruption: await self.handle_function_call_cancel(frame) del self._function_calls_in_progress[frame.tool_call_id] diff --git a/src/pipecat/processors/aggregators/llm_response_universal.py b/src/pipecat/processors/aggregators/llm_response_universal.py index 2854c8681..87f7b22e8 100644 --- a/src/pipecat/processors/aggregators/llm_response_universal.py +++ b/src/pipecat/processors/aggregators/llm_response_universal.py @@ -858,10 +858,8 @@ class LLMAssistantAggregator(LLMContextAggregator): logger.debug( f"{self} FunctionCallCancelFrame: [{frame.function_name}:{frame.tool_call_id}]" ) - if frame.tool_call_id not in self._function_calls_in_progress: - return - - if self._function_calls_in_progress[frame.tool_call_id].cancel_on_interruption: + function_call = self._function_calls_in_progress.get(frame.tool_call_id) + if function_call and function_call.cancel_on_interruption: # Update context with the function call cancellation self._update_function_call_result(frame.function_name, frame.tool_call_id, "CANCELLED") del self._function_calls_in_progress[frame.tool_call_id]