Skip to content

Refactor to use singledispatch send_email() and to_email() #22

Description

@machow

send_email()

# maybe clients.py ----
@dataclass
class Gmail:
    username: str
    password: str

@dataclass
class Smtp:
    host: str
    port: int
    username: str
    password: str
    security: str # Literal


# egress.py ----

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import overloads as dispatch
else:
    from ddispatch import dispatch


@dispatch
def send_email(client: Gmail, i_email):
    ...
    # logic here...
    

@dispatch
def send_email(client: Smtp, i_email):
    ...
    # logic here...

to_email()

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import overloads as dispatch
else:
    from ddispatch import dispatch

from email.message import EmailMessage
from .mjml import MJMLTag

@dispatch
def to_email(msg: EmailMessage):
    ...

@dispatch
def to_email(MJMLTag):
    ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions