mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix: use duck-type in test _get_file_size; fix AsyncGenerator return type annotation
This commit is contained in:
parent
6a9b84e788
commit
3a49b5b879
2 changed files with 5 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ import ssl
|
|||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
AsyncGenerator,
|
||||
AsyncIterator,
|
||||
Coroutine,
|
||||
Dict,
|
||||
|
|
@ -154,7 +155,7 @@ else:
|
|||
|
||||
async def _async_file_chunks(
|
||||
fp: Any, chunk_size: int = 65536
|
||||
) -> "AsyncIterator[bytes]":
|
||||
) -> "AsyncGenerator[bytes, None]":
|
||||
"""Async generator that reads a sync file-like object in chunks via a thread executor.
|
||||
|
||||
Dispatches each blocking disk read to a thread pool via anyio so the async
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import io
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Union
|
||||
from typing import Any, Union
|
||||
from unittest.mock import ANY
|
||||
|
||||
import pytest
|
||||
|
|
@ -25,9 +25,9 @@ from litellm.types.llms.openai import OpenAIFileObject
|
|||
client = TestClient(app)
|
||||
|
||||
|
||||
def _get_file_size(file_content: Union[bytes, io.IOBase]) -> int:
|
||||
def _get_file_size(file_content: Union[bytes, Any]) -> int:
|
||||
"""Return file size without loading IO objects fully into memory."""
|
||||
if isinstance(file_content, io.IOBase):
|
||||
if hasattr(file_content, "read") and hasattr(file_content, "seek"):
|
||||
pos = file_content.tell()
|
||||
file_content.seek(0, 2)
|
||||
size = file_content.tell()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue