fix: export PermissionDeniedError from litellm.__init__
PermissionDeniedError (403) is defined in litellm/exceptions.py but was never added to the import block in litellm/__init__.py. This makes it the only standard HTTP error exception not accessible as litellm.PermissionDeniedError, forcing users to import from litellm.exceptions directly. Fixes #20959
This commit is contained in:
parent
a9255349b6
commit
2ef0d9e80a
@ -1155,6 +1155,7 @@ from .exceptions import (
|
||||
BadRequestError,
|
||||
ImageFetchError,
|
||||
NotFoundError,
|
||||
PermissionDeniedError,
|
||||
RateLimitError,
|
||||
ServiceUnavailableError,
|
||||
BadGatewayError,
|
||||
|
||||
31
tests/test_litellm/test_exception_exports.py
Normal file
31
tests/test_litellm/test_exception_exports.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""
|
||||
Test that all standard HTTP error exceptions are exported from litellm.__init__.
|
||||
"""
|
||||
|
||||
import litellm
|
||||
|
||||
|
||||
def test_permission_denied_error_is_exported():
|
||||
"""PermissionDeniedError (403) should be accessible as litellm.PermissionDeniedError."""
|
||||
assert hasattr(litellm, "PermissionDeniedError")
|
||||
assert litellm.PermissionDeniedError is not None
|
||||
|
||||
|
||||
def test_all_http_error_exceptions_exported():
|
||||
"""All standard HTTP error exceptions should be accessible at module level."""
|
||||
expected_exceptions = [
|
||||
"BadRequestError", # 400
|
||||
"AuthenticationError", # 401
|
||||
"PermissionDeniedError", # 403
|
||||
"NotFoundError", # 404
|
||||
"Timeout", # 408
|
||||
"UnprocessableEntityError", # 422
|
||||
"RateLimitError", # 429
|
||||
"InternalServerError", # 500
|
||||
"BadGatewayError", # 502
|
||||
"ServiceUnavailableError", # 503
|
||||
]
|
||||
for exc_name in expected_exceptions:
|
||||
assert hasattr(litellm, exc_name), (
|
||||
f"litellm.{exc_name} is not exported from litellm.__init__"
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user