Skip to content

Commit 3866a9b

Browse files
Make boto3 optional (#197)
1 parent 1f543bc commit 3866a9b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

mangum/backends/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
except ImportError: # pragma: no cover
1212
httpx = None # type: ignore
1313

14-
import boto3
15-
from botocore.auth import SigV4Auth
16-
from botocore.awsrequest import AWSRequest
14+
try:
15+
import boto3
16+
from botocore.auth import SigV4Auth
17+
from botocore.awsrequest import AWSRequest
18+
except ImportError: # pragma: no cover
19+
boto3 = None # type: ignore
20+
1721

1822
from .base import WebSocketBackend
1923
from ..exceptions import WebSocketError, ConfigurationError
@@ -49,6 +53,9 @@ class WebSocket:
4953
api_gateway_region_name: Optional[str] = None
5054

5155
def __post_init__(self, dsn: Optional[str]) -> None:
56+
if boto3 is None: # pragma: no cover
57+
raise WebSocketError("boto3 must be installed to use WebSockets.")
58+
5259
if httpx is None: # pragma: no cover
5360
raise WebSocketError("httpx must be installed to use WebSockets.")
5461

0 commit comments

Comments
 (0)