mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
Make email.policy classes generic (#12724)
This commit is contained in:
@@ -1,16 +1,34 @@
|
||||
from collections.abc import Callable
|
||||
from email._policybase import Compat32 as Compat32, Policy as Policy, compat32 as compat32
|
||||
from email._policybase import Compat32 as Compat32, Policy as Policy, _MessageFactory, compat32 as compat32
|
||||
from email.contentmanager import ContentManager
|
||||
from email.message import Message
|
||||
from typing import Any
|
||||
from email.message import EmailMessage, Message
|
||||
from typing import Any, TypeVar, overload
|
||||
|
||||
__all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"]
|
||||
|
||||
class EmailPolicy(Policy):
|
||||
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
|
||||
|
||||
class EmailPolicy(Policy[_MessageT]):
|
||||
utf8: bool
|
||||
refold_source: str
|
||||
header_factory: Callable[[str, Any], Any]
|
||||
content_manager: ContentManager
|
||||
@overload
|
||||
def __init__(
|
||||
self: EmailPolicy[EmailMessage],
|
||||
*,
|
||||
max_line_length: int | None = ...,
|
||||
linesep: str = ...,
|
||||
cte_type: str = ...,
|
||||
raise_on_defect: bool = ...,
|
||||
mangle_from_: bool = ...,
|
||||
message_factory: None = None,
|
||||
utf8: bool = ...,
|
||||
refold_source: str = ...,
|
||||
header_factory: Callable[[str, str], str] = ...,
|
||||
content_manager: ContentManager = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -19,7 +37,7 @@ class EmailPolicy(Policy):
|
||||
cte_type: str = ...,
|
||||
raise_on_defect: bool = ...,
|
||||
mangle_from_: bool = ...,
|
||||
message_factory: Callable[[Policy], Message] | None = ...,
|
||||
message_factory: _MessageFactory[_MessageT] | None = ...,
|
||||
utf8: bool = ...,
|
||||
refold_source: str = ...,
|
||||
header_factory: Callable[[str, str], str] = ...,
|
||||
@@ -31,8 +49,8 @@ class EmailPolicy(Policy):
|
||||
def fold(self, name: str, value: str) -> Any: ...
|
||||
def fold_binary(self, name: str, value: str) -> bytes: ...
|
||||
|
||||
default: EmailPolicy
|
||||
SMTP: EmailPolicy
|
||||
SMTPUTF8: EmailPolicy
|
||||
HTTP: EmailPolicy
|
||||
strict: EmailPolicy
|
||||
default: EmailPolicy[EmailMessage]
|
||||
SMTP: EmailPolicy[EmailMessage]
|
||||
SMTPUTF8: EmailPolicy[EmailMessage]
|
||||
HTTP: EmailPolicy[EmailMessage]
|
||||
strict: EmailPolicy[EmailMessage]
|
||||
|
||||
Reference in New Issue
Block a user