fix(gemini): annotate alias set as Final, drop narrative comments

Addresses review feedback: the module constant now carries the `Final`
annotation required by LIT010, and the explanatory comments are folded
into the existing docstring so the source keeps to the repository's
comment convention.
This commit is contained in:
maya-lukas 2026-08-17 10:22:10 +02:00
parent 16b157f939
commit d7cbfc7759
2 changed files with 5 additions and 19 deletions

View file

@ -106,11 +106,7 @@ else:
StreamingChoices = Any
# Google's rolling aliases, which always resolve to the newest release of each
# tier and today serve Gemini 3.x. They carry no version number, so they must be
# listed explicitly for Gemini 3 feature detection to see them.
# https://ai.google.dev/gemini-api/docs/models
GEMINI_ROLLING_LATEST_ALIASES = frozenset(
GEMINI_ROLLING_LATEST_ALIASES: Final[frozenset[str]] = frozenset(
{
"gemini-flash-latest",
"gemini-flash-lite-latest",
@ -279,20 +275,14 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
- gemini-3.1-pro-preview, gemini-3.1-flash, gemini-3.1-flash-lite-preview
- gemini-3.5-flash
- Any future Gemini 3.x models
- The rolling `-latest` aliases, which Google keeps pointed at the
newest release of each tier and which currently serve Gemini 3.x.
The `-latest` aliases are matched by exact name rather than by an
`endswith("-latest")` suffix check, because versioned names such as
`gemini-2.5-flash-native-audio-latest` also end in `-latest` and are
not Gemini 3.
- GEMINI_ROLLING_LATEST_ALIASES, which resolve to Gemini 3.x and carry
no version number of their own. Matched by exact name, since
versioned names such as `gemini-2.5-flash-native-audio-latest` also
end in `-latest` yet are not Gemini 3
"""
# Check for Gemini 3 models
if "gemini-3" in model:
return True
# Rolling aliases carry no version in the name, so the substring check
# above cannot see them. Strip any provider prefix (`gemini/`,
# `vertex_ai/`) before comparing.
return model.split("/")[-1] in GEMINI_ROLLING_LATEST_ALIASES
@staticmethod

View file

@ -2275,8 +2275,6 @@ def test_is_gemini_3_or_newer():
# Edge cases
assert VertexGeminiConfig._is_gemini_3_or_newer("") == False
# Rolling `-latest` aliases resolve to Gemini 3.x and carry no version in
# the name, so they must be detected explicitly.
assert VertexGeminiConfig._is_gemini_3_or_newer("gemini-flash-latest") == True
assert VertexGeminiConfig._is_gemini_3_or_newer("gemini-flash-lite-latest") == True
assert VertexGeminiConfig._is_gemini_3_or_newer("gemini-pro-latest") == True
@ -2287,7 +2285,6 @@ def test_is_gemini_3_or_newer():
VertexGeminiConfig._is_gemini_3_or_newer("vertex_ai/gemini-pro-latest") == True
)
# A versioned name that merely ends in `-latest` is not Gemini 3.
assert (
VertexGeminiConfig._is_gemini_3_or_newer(
"gemini-2.5-flash-native-audio-latest"
@ -2339,7 +2336,6 @@ def test_thought_signature_fallback_for_rolling_latest_alias():
"thoughtSignature" in part for part in parts
), f"expected a thought signature for {model}"
# Pre-Gemini-3 models must not gain a signature they never needed.
parts = convert_to_gemini_tool_call_invoke(message, model="gemini-2.5-flash")
assert not any("thoughtSignature" in part for part in parts)