Skip to content

Commit e631d30

Browse files
committed
fix: use typed variable for response output to satisfy pyright
Fixes microsoft#6235 Use getattr with None fallback for the output attribute, and assign to a typed list variable before the match statement to help pyright narrow the response item types correctly.
1 parent b35707c commit e631d30

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎python/packages/openai/agent_framework_openai/_chat_client.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,8 @@ def _parse_response_from_openai(
19711971
metadata: dict[str, Any] = response.metadata or {}
19721972
contents: list[Content] = []
19731973
local_shell_tool_name = self._get_local_shell_tool_name(options.get("tools"))
1974-
for item in getattr(response, "output", []): # type: ignore[reportUnknownMemberType]
1974+
outputs: list = getattr(response, "output", None) or []
1975+
for item in outputs:
19751976
match item.type:
19761977
# types:
19771978
# ParsedResponseOutputMessage[Unknown] |

0 commit comments

Comments
 (0)