Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions python/b_fast/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

try:
from fastapi import Response

FASTAPI_AVAILABLE = True
except ImportError:
# Fallback class to prevent crash on import
class Response:
class Response:
def __init__(self, *args, **kwargs):
pass

FASTAPI_AVAILABLE = False


Expand All @@ -16,11 +18,13 @@ class BFastResponse(Response):

def __init__(self, content: Any, **kwargs):
if not FASTAPI_AVAILABLE:
raise ImportError("FastAPI is required to use BFastResponse. Install it with 'pip install fastapi'.")

raise ImportError(
"FastAPI is required to use BFastResponse. Install it with 'pip install fastapi'."
)

# Delayed import to avoid circular dependency
from ._b_fast import BFast

super().__init__(content=content, **kwargs)
self.encoder = BFast()

Expand Down
Loading