Skip to content

Commit

Permalink
refactor: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
badayvedat committed Jan 15, 2025
1 parent 85b3cdf commit 0982e5b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions projects/fal/src/fal/toolkit/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@

class DownloadFileMixin:
@contextmanager
def as_file(self) -> Generator[Path, None, None]:
def as_temp_file(self) -> Generator[Path, None, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield download_file(str(self), temp_dir)


class DownloadImageMixin:
@contextmanager
def as_pil_image(self):
yield read_image_from_url(str(self))
def to_pil(self):
return read_image_from_url(str(self))


class DataUri(DownloadFileMixin, str):
Expand Down Expand Up @@ -128,11 +127,6 @@ def validate(cls, value: Any) -> "HttpsUrl":
def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
update_not_none(field_schema, format="https-url")

@contextmanager
def as_file(self):
with tempfile.TemporaryDirectory() as temp_dir:
yield download_file(self, temp_dir)


class ImageHttpsUrl(DownloadImageMixin, HttpsUrl):
pass
Expand Down

0 comments on commit 0982e5b

Please sign in to comment.