From a0b9dea9b11ea2f9e20bf06735fb661636b5458b Mon Sep 17 00:00:00 2001 From: Sashank006 Date: Sat, 22 Aug 2026 23:12:44 -0500 Subject: [PATCH] fix: import NotRequired/assert_never from typing_extensions for py3.10 --- .../context_management/editors/compact.py | 4 ++-- litellm/proxy/common_utils/reset_budget_job.py | 3 ++- .../proxy/openai_files_endpoints/batch_file_validation.py | 3 ++- tests/test_litellm/test_py310_typing_imports.py | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/test_litellm/test_py310_typing_imports.py diff --git a/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py b/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py index 2a87afb5990..24b53152e7a 100644 --- a/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py +++ b/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py @@ -14,9 +14,9 @@ Mirrors Anthropic's native ``compact_20260112`` for non-Anthropic providers: import re from collections.abc import Mapping, Sequence -from typing import TYPE_CHECKING, Any, Final, Literal, NotRequired, Optional, TypedDict, Union, cast +from typing import TYPE_CHECKING, Any, Final, Literal, Optional, TypedDict, Union, cast -from typing_extensions import ReadOnly +from typing_extensions import NotRequired, ReadOnly import litellm from litellm._logging import verbose_logger diff --git a/litellm/proxy/common_utils/reset_budget_job.py b/litellm/proxy/common_utils/reset_budget_job.py index 8fcb184b26a..b78815d2455 100644 --- a/litellm/proxy/common_utils/reset_budget_job.py +++ b/litellm/proxy/common_utils/reset_budget_job.py @@ -6,7 +6,8 @@ from dataclasses import dataclass from datetime import datetime, timezone from enum import Enum from types import MappingProxyType -from typing import Final, Literal, Protocol, TypeVar, assert_never +from typing import Final, Literal, Protocol, TypeVar +from typing_extensions import assert_never import litellm from litellm._logging import verbose_proxy_logger diff --git a/litellm/proxy/openai_files_endpoints/batch_file_validation.py b/litellm/proxy/openai_files_endpoints/batch_file_validation.py index 0aee5e8cc54..5d05a4dd0d7 100644 --- a/litellm/proxy/openai_files_endpoints/batch_file_validation.py +++ b/litellm/proxy/openai_files_endpoints/batch_file_validation.py @@ -2,7 +2,8 @@ import json from collections.abc import Iterator from dataclasses import dataclass from itertools import chain -from typing import BinaryIO, Final, NoReturn, assert_never +from typing import BinaryIO, Final, NoReturn +from typing_extensions import assert_never from litellm.proxy._types import ProxyException diff --git a/tests/test_litellm/test_py310_typing_imports.py b/tests/test_litellm/test_py310_typing_imports.py new file mode 100644 index 00000000000..0f50e352a59 --- /dev/null +++ b/tests/test_litellm/test_py310_typing_imports.py @@ -0,0 +1,6 @@ +import litellm + + +def test_import_litellm_succeeds(): + # regression for py3.10 typing imports (requires-python >=3.10) + assert hasattr(litellm, "completion")