Skip to content

Commit

Permalink
fix aiofiles dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 7, 2024
1 parent 473462e commit 5663470
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/codeboxapi/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import typing as t
from dataclasses import dataclass

import aiofiles

from .codebox import CodeBox


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

async def asave(self, local_path: str) -> None:
try:
import aiofiles # type: ignore
except ImportError:
raise RuntimeError(
"aiofiles is not installed. Please install it with "
'`pip install "codeboxapi[local]"`'
)

async with aiofiles.open(local_path, "wb") as f:
async for chunk in self.remote.astream_download(self.path):
await f.write(chunk)
Expand Down

0 comments on commit 5663470

Please sign in to comment.