From b3d8a79bd4864c1f341a6dd8f0959f7e58c9e04a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 3 Sep 2026 01:17:12 +0000 Subject: [PATCH] test(proxy): type the env var regression test params and keep locals Final Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../proxy/test_litellm_pre_call_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py index 779d06899cb..f5422094f5e 100644 --- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py +++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py @@ -8,6 +8,7 @@ import textwrap import time from datetime import datetime, timezone from types import SimpleNamespace +from typing import Final from unittest.mock import AsyncMock, MagicMock, patch import pytest @@ -4958,12 +4959,13 @@ def test_apply_overrides_feature_flag_disabled_by_default(): "env_value, expected", [("true", True), ("True", True), ("false", False), (None, False)], ) -def test_credential_overrides_flag_reads_env_var_at_import(env_value, expected): +def test_credential_overrides_flag_reads_env_var_at_import(env_value: str | None, expected: bool): """LITELLM_ENABLE_MODEL_CONFIG_CREDENTIAL_OVERRIDES is read at import, so check it in a fresh interpreter.""" - env = {k: v for k, v in os.environ.items() if k != "LITELLM_ENABLE_MODEL_CONFIG_CREDENTIAL_OVERRIDES"} - if env_value is not None: - env["LITELLM_ENABLE_MODEL_CONFIG_CREDENTIAL_OVERRIDES"] = env_value - result = subprocess.run( + base_env: Final = {k: v for k, v in os.environ.items() if k != "LITELLM_ENABLE_MODEL_CONFIG_CREDENTIAL_OVERRIDES"} + env: Final = ( + base_env if env_value is None else {**base_env, "LITELLM_ENABLE_MODEL_CONFIG_CREDENTIAL_OVERRIDES": env_value} + ) + result: Final = subprocess.run( [ sys.executable, "-c",