From 66443233afa6ffffa82a119a44b1fc5a7bbf65d0 Mon Sep 17 00:00:00 2001 From: Jules <54960783+juleswg23@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:50:34 -0400 Subject: [PATCH] make attachments default to empty list/dict --- emailer_lib/structs.py | 6 +++--- emailer_lib/tests/test_structs.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/emailer_lib/structs.py b/emailer_lib/structs.py index b3b8777..f338cfa 100644 --- a/emailer_lib/structs.py +++ b/emailer_lib/structs.py @@ -1,5 +1,5 @@ from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field import re from email.message import EmailMessage @@ -62,10 +62,10 @@ class IntermediateEmail: rsc_email_supress_scheduled: bool | None = None # is a list of files in path from current directory - external_attachments: list[str] | None = None + external_attachments: list[str] = field(default_factory=list) # has structure {filename: base64_string} - inline_attachments: dict[str, str] | None = None + inline_attachments: dict[str, str] = field(default_factory=dict) text: str | None = None # sometimes present in quarto recipients: list[str] | None = None # not present in quarto diff --git a/emailer_lib/tests/test_structs.py b/emailer_lib/tests/test_structs.py index b1103ab..e549c6c 100644 --- a/emailer_lib/tests/test_structs.py +++ b/emailer_lib/tests/test_structs.py @@ -27,8 +27,8 @@ def test_creation_without_text_and_attachments(): ) assert email.text is None assert email.recipients is None - assert email.external_attachments is None - assert email.inline_attachments is None + assert email.external_attachments == [] + assert email.inline_attachments == {} assert email.subject == "No Text or Attachments" @@ -94,4 +94,4 @@ def test_not_implemented_methods(method_name): ) method = getattr(email, method_name) with pytest.raises(NotImplementedError): - method() \ No newline at end of file + method()