From 256f1ecc1bd6e5c1464fc491b208768d426f100c Mon Sep 17 00:00:00 2001 From: Yassin Kortam Date: Mon, 3 Aug 2026 13:57:40 -0700 Subject: [PATCH] fix(openai): repair the annotation that makes litellm unimportable `BaseOpenAILLM.owns_wrapped_http_client` annotates its parameter with `Optional[Union[httpx.Client, httpx.AsyncClient]]`, but `Union` was never added to the module's typing import. The annotation is evaluated when the class body executes, so `import litellm` raises `NameError: name 'Union' is not defined` and every module that imports litellm dies with it. litellm_internal_staging is red from this: `cd litellm && ruff check .` reports F821 and the whole test matrix fails on import, on every open PR, because CI evaluates the PR merged into the current staging tip. The annotation becomes `httpx.Client | httpx.AsyncClient | None` rather than gaining a `Union` import. requires-python is >=3.10, so PEP 604 unions evaluate at runtime, and UP007 and UP045 both sit at a ceiling of 0 in ruff-strict-budget.json, so importing `Union` would trade the F821 for a budget failure. --- litellm/llms/openai/common_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/openai/common_utils.py b/litellm/llms/openai/common_utils.py index 082764df2087..808998ddaf6f 100644 --- a/litellm/llms/openai/common_utils.py +++ b/litellm/llms/openai/common_utils.py @@ -135,7 +135,7 @@ def get_cached_openai_client( return _cached_client @staticmethod - def owns_wrapped_http_client(http_client: Optional[Union[httpx.Client, httpx.AsyncClient]]) -> bool: + def owns_wrapped_http_client(http_client: httpx.Client | httpx.AsyncClient | None) -> bool: """Whether litellm may close an SDK client built around ``http_client``. ``_get_async_http_client`` / ``_get_sync_http_client`` hand back