mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(openai): restore httpx client union type on owns_wrapped_http_client (#35706)
PR #35492 was authored before the ruff sweep removed Union from the typing imports in litellm/llms/openai/common_utils.py, so the merge landed an annotation referencing Union without an import. The annotation is evaluated at class-definition time, so importing litellm raises NameError and every test shard on litellm_internal_staging fails at collection. Rewrites the annotation (and the same latent one in openai.py) as httpx.Client | httpx.AsyncClient | None, matching the file's PEP 604 style, so no typing import is needed at all.
This commit is contained in:
parent
9d5984b358
commit
a6d4654261
2 changed files with 2 additions and 2 deletions
|
|
@ -135,7 +135,7 @@ class BaseOpenAILLM:
|
||||||
return _cached_client
|
return _cached_client
|
||||||
|
|
||||||
@staticmethod
|
@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``.
|
"""Whether litellm may close an SDK client built around ``http_client``.
|
||||||
|
|
||||||
``_get_async_http_client`` / ``_get_sync_http_client`` hand back
|
``_get_async_http_client`` / ``_get_sync_http_client`` hand back
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):
|
||||||
if cached_client:
|
if cached_client:
|
||||||
if isinstance(cached_client, OpenAI) or isinstance(cached_client, AsyncOpenAI):
|
if isinstance(cached_client, OpenAI) or isinstance(cached_client, AsyncOpenAI):
|
||||||
return cached_client
|
return cached_client
|
||||||
http_client: Optional[Union[httpx.Client, httpx.AsyncClient]] = (
|
http_client: httpx.Client | httpx.AsyncClient | None = (
|
||||||
OpenAIChatCompletion._get_async_http_client(shared_session=shared_session)
|
OpenAIChatCompletion._get_async_http_client(shared_session=shared_session)
|
||||||
if is_async
|
if is_async
|
||||||
else OpenAIChatCompletion._get_sync_http_client()
|
else OpenAIChatCompletion._get_sync_http_client()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue