From 2f74a5136079985d4ad39bf9d35010d115c19bb0 Mon Sep 17 00:00:00 2001 From: Chenglun Hu Date: Wed, 15 Jul 2026 22:37:29 +0800 Subject: [PATCH] chore: ruff format core_helpers + test --- litellm/litellm_core_utils/core_helpers.py | 16 ++++++++-------- .../litellm_core_utils/test_core_helpers.py | 6 +----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index 94b75ff0a76..15497a3323c 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -682,11 +682,13 @@ def filter_exceptions_from_params(data: object, max_depth: int = 20) -> Any: # filtering the full `all_litellm_params` (api_key/num_retries/...) would break # the call, and knobs like stream_chunk_size are read downstream (converse # streaming) so they are not internal. See #30301. -MCP_INTERNAL_REQUEST_KEYS: set = { - "skip_mcp_handler", - "mcp_handler_context", - "_skip_mcp_handler", -} +MCP_INTERNAL_REQUEST_KEYS: Final = frozenset( + ( + "skip_mcp_handler", + "mcp_handler_context", + "_skip_mcp_handler", + ) +) def filter_internal_params(data: dict, additional_internal_params: set | None = None) -> dict: @@ -707,9 +709,7 @@ def filter_internal_params(data: dict, additional_internal_params: set | None = if not isinstance(data, dict): return data - internal_params = set(MCP_INTERNAL_REQUEST_KEYS) - if additional_internal_params: - internal_params.update(additional_internal_params) + internal_params: Final = MCP_INTERNAL_REQUEST_KEYS | frozenset(additional_internal_params or ()) return {k: v for k, v in data.items() if k not in internal_params} diff --git a/tests/test_litellm/litellm_core_utils/test_core_helpers.py b/tests/test_litellm/litellm_core_utils/test_core_helpers.py index ec890d9fe9e..602678c62c1 100644 --- a/tests/test_litellm/litellm_core_utils/test_core_helpers.py +++ b/tests/test_litellm/litellm_core_utils/test_core_helpers.py @@ -7,16 +7,12 @@ import pytest from litellm.litellm_core_utils.core_helpers import ( _FINISH_REASON_MAP, -<<<<<<< HEAD - LITELLM_INTERNAL_PARAMS, + MCP_INTERNAL_REQUEST_KEYS, RESPONSE_COST_HEADER, bind_budget_reservation_to_callbacks, budget_reservation_from_metadata, drop_params_env_flag, drop_params_flag, -======= - MCP_INTERNAL_REQUEST_KEYS, ->>>>>>> 8957cc20e7 (rename constant to MCP_INTERNAL_REQUEST_KEYS per review (avoid all_litellm_params name echo)) filter_internal_params, get_or_create_metadata_bucket, get_provider_response_headers_from_hidden_params,