Clean up and fix email message types (#13532)

* Unify the `_MessageT` type var in `email._policybase`.
* Use explicit type arguments for `Message` type in `_MessageT` type var.
  In particular, change bound from `Message[str, str]` to `Message[Any, Any]`.
* Change `__init__()` overloads of `Parser` and `BytesParser` to accept
  `Message` objects that are not `Message[str, str]` if `_class` is not also given.
This commit is contained in:
Sebastian Rittau
2025-05-05 11:59:51 -04:00
committed by GitHub
parent a43e0a4c02
commit 0eb44e574c
11 changed files with 42 additions and 25 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
from email._policybase import _MessageT
from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy, _MessageT
from email.policy import Policy
__all__ = ["MIMEMessage"]
+2 -1
View File
@@ -1,7 +1,8 @@
from collections.abc import Sequence
from email import _ParamsType
from email._policybase import _MessageT
from email.mime.base import MIMEBase
from email.policy import Policy, _MessageT
from email.policy import Policy
__all__ = ["MIMEMultipart"]