fix(cost): drop the or {} default so the metadata read adds no LIT002

The type-discipline gate failed on this PR: LIT002 (mutable-collection
construction) totalled 27149 against a ceiling of 27146, both new hits on
the `_cm_litellm_params.get("metadata", {}) or {}` line.

The two dict literals were only there to make the read total; a truthiness
check on the value does the same job and constructs nothing. Behaviour is
unchanged for every input: a missing, None or empty `metadata` leaves
`_custom_model_info` as None either way.

This copies the extraction in the video-generation path a few lines above,
which still carries the `or {}` form. That one is inside the gate's existing
budget, so it is left alone rather than reformatted in an unrelated PR.

scripts/type_discipline_gate.py --base b4f5e46a now reports "every LIT rule
is within its codebase ceiling"; tests/test_litellm/test_ocr_custom_pricing.py
is 8 passed.
This commit is contained in:
Mihidum Hettiyahandi 2026-08-17 13:50:49 +10:00
parent e2595e7acf
commit c77b5bada5

View file

@ -1590,13 +1590,16 @@ def completion_cost(
# Deployment-specific model_info, for modalities whose pricing is
# not token-based and so cannot travel via custom_cost_per_token
# (e.g. OCR per-page pricing). Same extraction as the video path.
# (e.g. OCR per-page pricing). Same extraction as the video path
# above, minus its `or {}` default: truthiness on the value adds
# no mutable-collection construction (LIT002) and reads the same.
_custom_model_info: ModelInfo | None = None
if custom_pricing and litellm_logging_obj is not None:
_cm_litellm_params = getattr(litellm_logging_obj, "litellm_params", None)
if _cm_litellm_params is not None:
_cm_metadata = _cm_litellm_params.get("metadata", {}) or {}
_custom_model_info = _cm_metadata.get("model_info", None)
_cm_metadata = _cm_litellm_params.get("metadata")
if _cm_metadata:
_custom_model_info = _cm_metadata.get("model_info", None)
(
prompt_tokens_cost_usd_dollar,