fix: resolve MyPy type errors in conditional dict unpacking

Replace `**({...} if cond else {})` pattern with direct dict mutation
to avoid MyPy's inability to infer the correct type from conditional
expressions in **kwargs unpacking.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jesset 2026-05-03 17:29:37 +08:00
parent 658dd66c83
commit ae33744893
2 changed files with 4 additions and 4 deletions

View file

@ -771,15 +771,15 @@ class WebSearchInterceptionLogger(CustomLogger):
followup_kwargs = dict(request_patch.kwargs)
if _followup_api_key is not None:
followup_kwargs.pop("api_key", None)
followup_kwargs["api_key"] = _followup_api_key
if _followup_api_base is not None:
followup_kwargs.pop("api_base", None)
followup_kwargs["api_base"] = _followup_api_base
return await anthropic_messages.acreate(
max_tokens=max_tokens,
messages=request_patch.messages,
model=request_patch.model or model,
**({"api_key": _followup_api_key} if _followup_api_key else {}),
**({"api_base": _followup_api_base} if _followup_api_base else {}),
**optional_params,
**followup_kwargs,
)

View file

@ -4683,8 +4683,10 @@ class BaseLLMHTTPHandler:
# api_key or api_base, so agentic credentials take precedence.
if agentic_api_key is not None:
kwargs_for_followup.pop("api_key", None)
kwargs_for_followup["api_key"] = agentic_api_key
if agentic_api_base is not None:
kwargs_for_followup.pop("api_base", None)
kwargs_for_followup["api_base"] = agentic_api_base
return await anthropic_messages.acreate(
**{
@ -4692,8 +4694,6 @@ class BaseLLMHTTPHandler:
"messages": patch.messages,
"model": patch.model or full_model_name,
"stream": stream,
**({"api_key": agentic_api_key} if agentic_api_key else {}),
**({"api_base": agentic_api_base} if agentic_api_base else {}),
**optional_params,
**kwargs_for_followup,
}