From 3854079b52b3395ba59526b9b730b4cc40ede4b9 Mon Sep 17 00:00:00 2001 From: Ionite Date: Thu, 2 Mar 2023 17:14:32 -0500 Subject: Refactor FileAttachment.save_to() to return the saved file Path object --- snekbox/snekio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snekbox/snekio.py b/snekbox/snekio.py index 45ebc61..821f057 100644 --- a/snekbox/snekio.py +++ b/snekbox/snekio.py @@ -80,12 +80,13 @@ class FileAttachment: """Size of the attachment.""" return len(self.content) - def save_to(self, directory: Path | str) -> None: - """Write the attachment to a file in `directory`.""" + def save_to(self, directory: Path | str) -> Path: + """Write the attachment to a file in `directory`. Return a Path of the file.""" file = Path(directory, self.path) # Create directories if they don't exist file.parent.mkdir(parents=True, exist_ok=True) file.write_bytes(self.content) + return file @cached_property def as_dict(self) -> dict[str, str | int]: -- cgit v1.2.3