From 67d4471a378d12bce2f061ac39dcc2633742acf1 Mon Sep 17 00:00:00 2001 From: yucheng Date: Wed, 23 Sep 2026 15:43:47 +0000 Subject: [PATCH] fix(batches): keep cast-ok tags on the flagged cast lines for the discipline gate Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/litellm_core_utils/core_helpers.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index 088a4a41428..0bcf222ec6b 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -770,11 +770,9 @@ def set_response_cost_in_hidden_params(response: _CarriesHiddenParams, cost: flo def is_batch_line_item_event(kwargs: object) -> bool: if not isinstance(kwargs, Mapping): return False - litellm_params: Final = cast(Mapping[str, object], kwargs).get( - "litellm_params" - ) # cast-ok: isinstance narrows only to unparameterized Mapping + typed_kwargs: Final = cast(Mapping[str, object], kwargs) # cast-ok: isinstance leaves Mapping unparameterized + litellm_params: Final = typed_kwargs.get("litellm_params") if not isinstance(litellm_params, Mapping): return False - return bool( - cast(Mapping[str, object], litellm_params).get("batch_parent_id") - ) # cast-ok: same narrowing limit as above + typed_params: Final = cast(Mapping[str, object], litellm_params) # cast-ok: same narrowing limit + return bool(typed_params.get("batch_parent_id"))