From fbf50f2c07ef9757ffadf129f48f2fba34fb608e Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:23:51 -0700 Subject: [PATCH] fix(count_tokens): preserve typed validator return --- litellm/proxy/google_endpoints/endpoints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/google_endpoints/endpoints.py b/litellm/proxy/google_endpoints/endpoints.py index 61d1232ccec..3e63a15e128 100644 --- a/litellm/proxy/google_endpoints/endpoints.py +++ b/litellm/proxy/google_endpoints/endpoints.py @@ -1,7 +1,7 @@ from collections.abc import Mapping from itertools import chain from types import MappingProxyType -from typing import Final +from typing import Final, cast from fastapi import APIRouter, Depends, HTTPException, Request, Response from fastapi.responses import JSONResponse, ORJSONResponse @@ -37,7 +37,7 @@ class _GoogleCountTokensSystemInstruction(BaseModel): @field_validator("parts", mode="before") @classmethod def normalize_parts(cls, parts: object) -> object: - return (parts,) if isinstance(parts, Mapping) else parts + return (cast(object, parts),) if isinstance(parts, Mapping) else parts class _GoogleCountTokensFunctionDeclaration(BaseModel):