From 6a50ec53b2997e894d1e48e6d69ac34fc8f342c2 Mon Sep 17 00:00:00 2001 From: Johnny Wilson Dougherty <192861341+JohnnyWilson-Portfolio@users.noreply.github.com> Date: Fri, 11 Sep 2026 19:40:03 +0530 Subject: [PATCH] fix(responses): fix basedpyright final rebind and attribute access --- .../transformation.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index a2f69de15e8..4b0929f1b6e 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -451,11 +451,7 @@ class LiteLLMCompletionResponsesConfig: @staticmethod def _extract_system_content(message: object) -> tuple[str, ...]: - raw: Final = ( - message.get("content") - if isinstance(message, dict) - else (message.content if hasattr(message, "content") else None) - ) + raw: Final = message.get("content") if isinstance(message, dict) else getattr(message, "content", None) if isinstance(raw, str): return (raw,) if raw else () if isinstance(raw, list): @@ -465,7 +461,7 @@ class LiteLLMCompletionResponsesConfig: if isinstance(block, str) and block: yield block elif isinstance(block, dict): - text: Final = block.get("text") + text = block.get("text") # rebind-ok: loop variable if isinstance(text, str) and text: yield text @@ -498,7 +494,7 @@ class LiteLLMCompletionResponsesConfig: def _is_system(msg: object) -> bool: if isinstance(msg, dict): return msg.get("role") == "system" - return bool(hasattr(msg, "role") and msg.role == "system") + return bool(getattr(msg, "role", None) == "system") system_indices: Final = tuple(i for i, m in enumerate(messages) if _is_system(m)) if not system_indices or (len(system_indices) == 1 and system_indices[0] == 0):