From 25ff25d1efec311219f3fa29239f577fc2b2b394 Mon Sep 17 00:00:00 2001 From: Chesars Date: Mon, 26 Jan 2026 13:43:17 -0300 Subject: [PATCH 1/2] fix(containers): Fix Python 3.10 compatibility for OpenAIContainerConfig LiteLLM's pyproject.toml specifies `python = ">=3.9,<4.0"`, supporting Python 3.9 and above. However, the OpenAIContainerConfig class was failing to load on Python 3.10 with: TypeError: Cannot subclass typing.Any This occurred because `BaseContainerConfig = Any` was used as a runtime placeholder, and the class then inherited from it. In Python 3.11+, subclassing `typing.Any` is allowed (added to support dynamic classes like unittest.Mock where type checkers should skip verification). However, in Python 3.10 and earlier, this raises a TypeError. The fix imports the actual BaseContainerConfig class at runtime instead of using Any as a placeholder. Fixes #19727 --- litellm/llms/openai/containers/transformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/openai/containers/transformation.py b/litellm/llms/openai/containers/transformation.py index e67bfbe0c62..e8ab6190c74 100644 --- a/litellm/llms/openai/containers/transformation.py +++ b/litellm/llms/openai/containers/transformation.py @@ -29,7 +29,7 @@ if TYPE_CHECKING: BaseLLMException = _BaseLLMException else: LiteLLMLoggingObj = Any - BaseContainerConfig = Any + from ...base_llm.containers.transformation import BaseContainerConfig BaseLLMException = Any From 9c3de581823424e7defda4479b41ee868139343b Mon Sep 17 00:00:00 2001 From: Chesars Date: Fri, 30 Jan 2026 14:34:10 -0300 Subject: [PATCH 2/2] refactor(containers): simplify BaseContainerConfig import per review Move BaseContainerConfig import outside TYPE_CHECKING block since it's needed at runtime for class inheritance, not just for type hints. --- litellm/llms/openai/containers/transformation.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/litellm/llms/openai/containers/transformation.py b/litellm/llms/openai/containers/transformation.py index e8ab6190c74..b89204230ac 100644 --- a/litellm/llms/openai/containers/transformation.py +++ b/litellm/llms/openai/containers/transformation.py @@ -16,20 +16,17 @@ from litellm.types.containers.main import ( ) from litellm.types.router import GenericLiteLLMParams +from ...base_llm.containers.transformation import BaseContainerConfig + if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj from ...base_llm.chat.transformation import BaseLLMException as _BaseLLMException - from ...base_llm.containers.transformation import ( - BaseContainerConfig as _BaseContainerConfig, - ) LiteLLMLoggingObj = _LiteLLMLoggingObj - BaseContainerConfig = _BaseContainerConfig BaseLLMException = _BaseLLMException else: LiteLLMLoggingObj = Any - from ...base_llm.containers.transformation import BaseContainerConfig BaseLLMException = Any