We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 473462e commit 5663470Copy full SHA for 5663470
src/codeboxapi/types.py
@@ -1,8 +1,6 @@
1
import typing as t
2
from dataclasses import dataclass
3
4
-import aiofiles
5
-
6
from .codebox import CodeBox
7
8
@@ -45,6 +43,14 @@ def save(self, local_path: str) -> None:
45
43
f.write(chunk)
46
44
47
async def asave(self, local_path: str) -> None:
+ try:
+ 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
+
54
async with aiofiles.open(local_path, "wb") as f:
55
async for chunk in self.remote.astream_download(self.path):
56
await f.write(chunk)
0 commit comments