From 27325a255eb1ab8cde3ed122bb873ff224066ec4 Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Wed, 23 Oct 2024 10:17:13 -0400 Subject: [PATCH] Add `email.policy.EmailPolicy.clone` (#12879) --- stdlib/email/policy.pyi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index 5adf4a8c2..8a34b1840 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -3,6 +3,7 @@ from email._policybase import Compat32 as Compat32, Policy as Policy, _MessageFa from email.contentmanager import ContentManager from email.message import EmailMessage, Message from typing import Any, TypeVar, overload +from typing_extensions import Self __all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"] @@ -48,6 +49,22 @@ class EmailPolicy(Policy[_MessageT]): def header_fetch_parse(self, name: str, value: str) -> Any: ... def fold(self, name: str, value: str) -> Any: ... def fold_binary(self, name: str, value: str) -> bytes: ... + def clone( + self, + *, + max_line_length: int | None = ..., + linesep: str = ..., + cte_type: str = ..., + raise_on_defect: bool = ..., + mangle_from_: bool = ..., + message_factory: _MessageFactory[_MessageT] | None = ..., + # Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5 + verify_generated_headers: bool = ..., + utf8: bool = ..., + refold_source: str = ..., + header_factory: Callable[[str, str], str] = ..., + content_manager: ContentManager = ..., + ) -> Self: ... default: EmailPolicy[EmailMessage] SMTP: EmailPolicy[EmailMessage]