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"))