Skip to content

email.policy.default doesn't work with email.parser.BytesParser or email.parser.Parser #13531

Open
@dseomn

Description

I just started getting a mypy error that I think is caused by the same issue, but it doesn't look like this PR touches email.parser.BytesParser at all. Would it make sense to change that in this PR too? Or should I file a separate bug?

Error:

rock_paper_sand/report_test.py:465: error: Argument "policy" to "BytesParser" has incompatible type "EmailPolicy[EmailMessage]"; expected "Policy[Message[str, str]]"  [arg-type]

Code:

        message = typing.cast(
            email.message.EmailMessage,
            email.parser.BytesParser(policy=email.policy.default).parsebytes(
                mock_subprocess_run.mock_calls[0].kwargs["input"]
            ),
        )

Originally posted by @dseomn in #13274 (comment)

mypy 1.15.0 also complains about parser.Parser(policy=policy.default) so i continue to use 1.13.0 and changed my code to use message_from_string in anticipation of this PR's deployment. happy to see more commits, but merging this PR as-is would be a step in the right direction.

Le mieux est l'ennemi du bien.

Originally posted by @cossor in #13274 (comment)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions