Skip to content

Email example from python docs doesn't validate: Address as EmailMessage header #2863

@arjennienhuis

Description

@arjennienhuis

EmailMessage.__setitem__ should support Address as a value. At least the Python docs email example think it does. See https://docs.python.org/3/library/email.examples.html

test_mypy.py:

from email.message import EmailMessage
from email.headerregistry import Address

msg = EmailMessage()
msg['From'] = Address("Pepé Le Pew", "pepe", "example.com")

And then:

$ mypy test_mypy.py
test_mypy.py:5: error: Incompatible types in assignment (expression has type "Address", target has type "Union[str, Header]")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions