diff --git a/src/deepgram/core/file.py b/src/deepgram/core/file.py index 44b0d27c..ac9f097d 100644 --- a/src/deepgram/core/file.py +++ b/src/deepgram/core/file.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast +from typing import IO, Dict, List, Mapping, Optional, Tuple, Union # File typing inspired by the flexibility of types within the httpx library # https://github.com/encode/httpx/blob/master/httpx/_types.py @@ -49,19 +49,18 @@ def with_content_type(*, file: File, default_content_type: str) -> File: to the default_content_type value if not. """ if isinstance(file, tuple): - if len(file) == 2: - filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore + file_len = len(file) + if file_len == 2: + filename, content = file # type: ignore return (filename, content, default_content_type) - elif len(file) == 3: - filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore + elif file_len == 3: + filename, content, file_content_type = file # type: ignore out_content_type = file_content_type or default_content_type return (filename, content, out_content_type) - elif len(file) == 4: - filename, content, file_content_type, headers = cast( # type: ignore - Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file - ) + elif file_len == 4: + filename, content, file_content_type, headers = file # type: ignore out_content_type = file_content_type or default_content_type return (filename, content, out_content_type, headers) else: - raise ValueError(f"Unexpected tuple length: {len(file)}") + raise ValueError(f"Unexpected tuple length: {file_len}") return (None, file, default_content_type)