From 405a12783889945a314942a949a162f9186fca86 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Sep 2026 00:57:05 +0000 Subject: [PATCH] fix(fireworks-ai): drop banned typing.cast to a suppressed import for the copied pricing entry Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/fireworks_ai/cost_calculator.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/litellm/llms/fireworks_ai/cost_calculator.py b/litellm/llms/fireworks_ai/cost_calculator.py index 7bd01115a94..f323d78e22d 100644 --- a/litellm/llms/fireworks_ai/cost_calculator.py +++ b/litellm/llms/fireworks_ai/cost_calculator.py @@ -2,9 +2,11 @@ For calculating cost of fireworks ai serverless inference models. """ -from collections.abc import Mapping from datetime import datetime -from typing import Final, cast +from typing import ( + Final, + cast, # noqa: TID251 # the fallback entry is a dict copy of a ReadOnly TypedDict; no cast-free way to retype it +) from litellm.constants import ( FIREWORKS_AI_4_B, @@ -78,14 +80,11 @@ def _with_cache_read_fallback(model_info: ModelInfo) -> ModelInfo: return model_info effective: Final[dict[str, object]] = dict(model_info) effective["cache_read_input_token_cost"] = input_rate - off_peak: Final = effective.get("off_peak_pricing") - if isinstance(off_peak, Mapping): - off_peak_map: Final[Mapping[str, object]] = cast(Mapping[str, object], off_peak) - if "cache_read_input_token_cost" not in off_peak_map: - effective["off_peak_pricing"] = { - **off_peak_map, - "cache_read_input_token_cost": off_peak_map.get("input_cost_per_token", input_rate), - } + off_peak: Final = model_info.get("off_peak_pricing") + if off_peak is not None and "cache_read_input_token_cost" not in off_peak: + off_peak_copy: Final[dict[str, object]] = dict(off_peak) + off_peak_copy["cache_read_input_token_cost"] = off_peak_copy.get("input_cost_per_token", input_rate) + effective["off_peak_pricing"] = off_peak_copy return cast(ModelInfo, effective)