mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
fix(cli): drop enum.StrEnum so the CLI imports on Python 3.10
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
30f33a949b
commit
03e6dd051c
2 changed files with 16 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ import os
|
|||
import tempfile
|
||||
from collections.abc import Callable, Mapping
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType
|
||||
from typing import Annotated, Final
|
||||
|
|
@ -25,7 +25,7 @@ LITELLM_PROXY_API_KEY_ENV: Final = "LITELLM_PROXY_API_KEY"
|
|||
_REJECTED_STATUSES: Final = frozenset((401, 403))
|
||||
|
||||
|
||||
class ListingFailure(StrEnum):
|
||||
class ListingFailure(str, Enum):
|
||||
"""Why a proxy could not be listed, decided once where the HTTP outcome is classified.
|
||||
|
||||
`unreachable` means no response at all; the other kinds prove the proxy answered, so callers
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import inspect
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
|
|
@ -7,6 +8,7 @@ from pathlib import Path
|
|||
import pytest
|
||||
import requests
|
||||
|
||||
from litellm.proxy.client.cli.commands import pi
|
||||
from litellm.proxy.client.cli.commands.pi import (
|
||||
ListingFailure,
|
||||
ModelLimits,
|
||||
|
|
@ -20,6 +22,18 @@ from litellm.proxy.client.cli.commands.pi import (
|
|||
)
|
||||
|
||||
|
||||
def test_pi_module_has_no_strenum_import():
|
||||
"""enum.StrEnum is Python 3.11+; pyproject allows 3.10, so pi.py must not import it."""
|
||||
assert "StrEnum" not in inspect.getsource(pi)
|
||||
|
||||
|
||||
def test_listing_failure_is_str_enum():
|
||||
assert issubclass(ListingFailure, str)
|
||||
assert ListingFailure.REJECTED.value == "rejected"
|
||||
assert ListingFailure("rejected") is ListingFailure.REJECTED
|
||||
assert str(ListingFailure.REJECTED.value) == "rejected"
|
||||
|
||||
|
||||
class _FakeResponse:
|
||||
def __init__(self, status_code, payload=None):
|
||||
self.status_code = status_code
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue