Skip to content

Commit d16acd1

Browse files
committed
fix unavailable module
1 parent 3b4dd34 commit d16acd1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mystbin/client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from __future__ import annotations
2525

2626
import json
27-
from typing import TYPE_CHECKING, Optional
27+
from typing import Optional
2828

2929
import aiohttp
3030

@@ -33,8 +33,12 @@
3333
from .objects import Paste, PasteData
3434

3535

36-
if TYPE_CHECKING:
36+
try:
3737
import requests
38+
except ImportError:
39+
HAS_REQUESTS = False
40+
else:
41+
HAS_REQUESTS = True
3842

3943
__all__ = (
4044
"Client",
@@ -143,6 +147,9 @@ async def close(self) -> None:
143147

144148
class SyncClient:
145149
def __init__(self, *, session: Optional[requests.Session] = None) -> None:
150+
if HAS_REQUESTS is not True:
151+
raise RuntimeError("The `requests` addon is required to use the Sync client.")
152+
146153
self.session: requests.Session = session or requests.Session()
147154

148155
def post(self, content: str, syntax: Optional[str] = None) -> Paste:

0 commit comments

Comments
 (0)