Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwodder opened this issue Dec 21, 2024 · 0 comments · May be fixed by #13274
Open

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

jwodder opened this issue Dec 21, 2024 · 0 comments · May be fixed by #13274

Comments

@jwodder
Copy link
Contributor

jwodder commented Dec 21, 2024

(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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant