diff --git a/src/aind_slims_api/core.py b/src/aind_slims_api/core.py index 5ac76f0..58dfacd 100644 --- a/src/aind_slims_api/core.py +++ b/src/aind_slims_api/core.py @@ -172,7 +172,7 @@ def fetch_attachments_content(self) -> \ class Attachment(SlimsBaseModel): pk: int = Field(..., alias="attm_pk") - slims_api: Slims + slims_api: Optional[Slims] = None _slims_table: SLIMSTABLES = "Attachment" class Config: @@ -180,6 +180,8 @@ class Config: def fetch_content(self) -> Response: """Fetches the content of this attachment""" + if not self.slims_api: + raise ValueError("Initialized without slims_api.") return self.slims_api.get(f"repo/{self.pk}") # attm_pk: SlimsColumn