Skip to content

Commit

Permalink
Make boto3 optional (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaneremieff authored Jul 23, 2021
1 parent 1f543bc commit 3866a9b
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 3866a9b

Please sign in to comment.