Skip to content

Commit 5663470

Browse files
committed
fix aiofiles dependency issue
1 parent 473462e commit 5663470

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/codeboxapi/types.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import typing as t
22
from dataclasses import dataclass
33

4-
import aiofiles
5-
64
from .codebox import CodeBox
75

86

@@ -45,6 +43,14 @@ def save(self, local_path: str) -> None:
4543
f.write(chunk)
4644

4745
async def asave(self, local_path: str) -> None:
46+
try:
47+
import aiofiles # type: ignore
48+
except ImportError:
49+
raise RuntimeError(
50+
"aiofiles is not installed. Please install it with "
51+
'`pip install "codeboxapi[local]"`'
52+
)
53+
4854
async with aiofiles.open(local_path, "wb") as f:
4955
async for chunk in self.remote.astream_download(self.path):
5056
await f.write(chunk)

0 commit comments

Comments
 (0)