diff options
Diffstat (limited to 'accounts/backend/mail/dummy.py')
-rw-r--r-- | accounts/backend/mail/dummy.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/accounts/backend/mail/dummy.py b/accounts/backend/mail/dummy.py index 61e7b75..3de3dbe 100644 --- a/accounts/backend/mail/dummy.py +++ b/accounts/backend/mail/dummy.py @@ -2,7 +2,8 @@ from . import Backend -from accounts.utils import ensure_utf8 +from accounts import AccountsFlask +from jinja2.environment import TemplateModule FANCY_FORMAT = '''\ @@ -23,8 +24,10 @@ From: {sender} class DummyBackend(Backend): + format: str - def __init__(self, app, plain=False, format=None): + def __init__(self, app: AccountsFlask, plain: bool = False, + format: None = None) -> None: super(DummyBackend, self).__init__(app) self.plain = plain @@ -36,13 +39,16 @@ class DummyBackend(Backend): else: self.format = format - def _send(self, recipient, content): - body = content.body() + def _send(self, recipient: str, content: TemplateModule): + print(type(content)) + + # we can't typecheck things defined in templates + body = content.body() # type: ignore if not self.plain: body = "\n| ".join(body.split("\n")) - print((self.format.format( - subject=ensure_utf8(content.subject()), - sender=ensure_utf8(content.sender()), - to=ensure_utf8(recipient), - body=ensure_utf8(body)))) + print(self.format.format( + subject=content.subject(), # type: ignore + sender=content.sender(), # type: ignore + to=recipient, + body=body)) |