From 89236c4bd812d7eae080fea887f8f6c574b1ac31 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 23 Oct 2026 19:56:27 -0700 Subject: [PATCH] test: annotate the remaining new test locals with Final --- tests/unit/integrations/dotprompt/test_prompt_manager.py | 4 ++-- tests/unit/llms/compactifai/test_compactifai.py | 4 ++-- .../test_runway_image_generation_transformation.py | 9 +++++---- tests/unit/proxy/auth/test_mcp_ip_filtering.py | 5 +++-- tests/unit/proxy/client/cli/test_encryption_commands.py | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/unit/integrations/dotprompt/test_prompt_manager.py b/tests/unit/integrations/dotprompt/test_prompt_manager.py index 9e3ec77c2a8..cbf19fe7985 100644 --- a/tests/unit/integrations/dotprompt/test_prompt_manager.py +++ b/tests/unit/integrations/dotprompt/test_prompt_manager.py @@ -364,8 +364,8 @@ def test_load_prompts_from_json_data(): def test_load_prompts_from_json_data_skips_malformed_entries(): - manager = PromptManager(prompt_directory=str(Path(__file__).parent)) - initial_count = len(manager.prompts) + manager: Final = PromptManager(prompt_directory=str(Path(__file__).parent)) + initial_count: Final = len(manager.prompts) manager.load_prompts_from_json_data( { diff --git a/tests/unit/llms/compactifai/test_compactifai.py b/tests/unit/llms/compactifai/test_compactifai.py index cc3b8b6963b..56d5374f383 100644 --- a/tests/unit/llms/compactifai/test_compactifai.py +++ b/tests/unit/llms/compactifai/test_compactifai.py @@ -2,7 +2,7 @@ import json import os import sys from unittest.mock import AsyncMock, patch -from typing import Optional +from typing import Final, Optional import httpx import pytest @@ -287,7 +287,7 @@ def test_compactifai_malformed_response_body_raises_the_error_of_the_failing_loo from litellm.llms.compactifai.chat.transformation import CompactifAIChatConfig - raw_response = httpx.Response( + raw_response: Final = httpx.Response( 200, json=body, request=httpx.Request("POST", "https://api.compactif.ai/v1/chat/completions") ) diff --git a/tests/unit/llms/runwayml/image_generation/test_runway_image_generation_transformation.py b/tests/unit/llms/runwayml/image_generation/test_runway_image_generation_transformation.py index 9e1269a881d..7eec9541b98 100644 --- a/tests/unit/llms/runwayml/image_generation/test_runway_image_generation_transformation.py +++ b/tests/unit/llms/runwayml/image_generation/test_runway_image_generation_transformation.py @@ -1,3 +1,4 @@ +from typing import Final from unittest.mock import MagicMock import httpx @@ -19,7 +20,7 @@ def test_output_dict_with_non_string_values_still_yields_the_image(respx_mock): }, status_code=200, ) - created = httpx.Response( + created: Final = httpx.Response( 200, json={"id": "task_1", "status": "PENDING"}, request=httpx.Request( @@ -27,7 +28,7 @@ def test_output_dict_with_non_string_values_still_yields_the_image(respx_mock): ), ) - image_response = RunwayMLImageGenerationConfig().transform_image_generation_response( + image_response: Final = RunwayMLImageGenerationConfig().transform_image_generation_response( model="gen4_image", raw_response=created, model_response=ImageResponse(), @@ -42,7 +43,7 @@ def test_output_dict_with_non_string_values_still_yields_the_image(respx_mock): def test_non_object_task_body_raises_the_base_error_class(): - created = httpx.Response( + created: Final = httpx.Response( 200, json=["unexpected"], request=httpx.Request( @@ -65,7 +66,7 @@ def test_non_object_task_body_raises_the_base_error_class(): @pytest.mark.asyncio async def test_async_non_object_task_body_raises_the_base_error_class(): - created = httpx.Response( + created: Final = httpx.Response( 200, json=["unexpected"], request=httpx.Request( diff --git a/tests/unit/proxy/auth/test_mcp_ip_filtering.py b/tests/unit/proxy/auth/test_mcp_ip_filtering.py index 29084318229..c403daf733f 100644 --- a/tests/unit/proxy/auth/test_mcp_ip_filtering.py +++ b/tests/unit/proxy/auth/test_mcp_ip_filtering.py @@ -6,6 +6,7 @@ external callers only see servers with available_on_public_internet=True. """ import logging +from typing import Final from unittest.mock import MagicMock, patch import pytest @@ -177,9 +178,9 @@ class TestMCPClientIPExtraction: assert result == "203.0.113.5" def test_non_boolean_use_x_forwarded_for_never_trusts_xff(self): - request = _make_request("10.0.0.5", "203.0.113.9, 10.0.0.5") + request: Final = _make_request("10.0.0.5", "203.0.113.9, 10.0.0.5") - result = IPAddressUtils.get_mcp_client_ip( + result: Final = IPAddressUtils.get_mcp_client_ip( request, general_settings={ "use_x_forwarded_for": "false", diff --git a/tests/unit/proxy/client/cli/test_encryption_commands.py b/tests/unit/proxy/client/cli/test_encryption_commands.py index f230f964b95..6685d29fb7e 100644 --- a/tests/unit/proxy/client/cli/test_encryption_commands.py +++ b/tests/unit/proxy/client/cli/test_encryption_commands.py @@ -85,6 +85,6 @@ def test_migrate_prints_no_residual_status_for_a_residual_below_zero_or_nan(runn @pytest.mark.parametrize("report", [None, "done", {"residual_legacy": "3"}]) def test_migrate_malformed_report_fails(runner, report): _FakeHTTPClient.response = {"status": "success", "report": report} - result = runner.invoke(cli_main.cli, ["encryption", "migrate", "--check"]) + result: Final = runner.invoke(cli_main.cli, ["encryption", "migrate", "--check"]) assert result.exit_code != 0 assert "Unexpected" in result.output