Skip to content

Typeshed in mypy 1.14.0 prohibits using email.policy.default with email.message_from_string() #13273

Open
@jwodder

Description

(I'm not sure whether this is a mypy bug or a typeshed bug, but the mypy issue template says that problems with specific functions should be reported here, so ...)

Consider the following code:

from email import message_from_string, policy

with open("message.eml") as fp:
    source = fp.read()

msg = message_from_string(source, policy=policy.default)

I think it's clear that this code should be acceptable, but running mypy 1.14.0 on this produces the following error:

email-policy.py:6: error: Argument "policy" to "message_from_string" has incompatible type "EmailPolicy[EmailMessage]"; expected "Policy[Message[str, str]]"  [arg-type]

Metadata

Assignees

No one assigned

    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