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
This commit is contained in:
Chesars 2026-01-26 13:43:17 -03:00
parent aa4b0e0149
commit 25ff25d1ef

View file

@ -29,7 +29,7 @@ if TYPE_CHECKING:
BaseLLMException = _BaseLLMException
else:
LiteLLMLoggingObj = Any
BaseContainerConfig = Any
from ...base_llm.containers.transformation import BaseContainerConfig
BaseLLMException = Any