Skip to content

Commit

Permalink
Make boto3 optional (Kludex#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaneremieff authored and khamaileon committed Jan 13, 2024
1 parent ceef430 commit 17fa781
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mangum/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
except ImportError: # pragma: no cover
httpx = None # type: ignore

import boto3
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
try:
import boto3
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
except ImportError: # pragma: no cover
boto3 = None # type: ignore


from .base import WebSocketBackend
from ..exceptions import WebSocketError, ConfigurationError
Expand Down Expand Up @@ -49,6 +53,9 @@ class WebSocket:
api_gateway_region_name: Optional[str] = None

def __post_init__(self, dsn: Optional[str]) -> None:
if boto3 is None: # pragma: no cover
raise WebSocketError("boto3 must be installed to use WebSockets.")

if httpx is None: # pragma: no cover
raise WebSocketError("httpx must be installed to use WebSockets.")

Expand Down

0 comments on commit 17fa781

Please sign in to comment.