-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors
Description
0 dkg@bob:~$ cat test.py
#!/usr/bin/python3
from email.mime.text import MIMEText
from email.policy import SMTP
msg = MIMEText("this is the message\n",
"plain", policy=SMTP)
print(msg, end="")
0 dkg@bob:~$ mypy --strict ./test.py
test.py:7: error: Argument "policy" to "MIMEText" has incompatible type "EmailPolicy[EmailMessage]"; expected "Policy[Message[str, str]] | None" [arg-type]
Found 1 error in 1 file (checked 1 source file)
1 dkg@bob:~$
email.mime
objects can typically take a policy
option, but the default is compat32
, which can be found in the private email._policybase
submodule. But there are other common EmailPolicy
objects which are supposed to work there.
I'm not an expert in the python email
module type choices, It looks to me like the type signature for this argument should be loosened up to be a union of these two types, at least. This probably goes for all the comparable email.mime
constructors, not just MIMEText
.
I ran into this on a debian system with mypy
1.15.0-5 and python3-typeshed
0.0~git20241223.ea91db2-1, with python
3.13.
Metadata
Metadata
Assignees
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors