email.message: Allow any header value (#11574)

This commit is contained in:
Sebastian Rittau
2024-03-11 22:47:00 +01:00
committed by GitHub
parent 579d208b19
commit 4c5c5760cf
2 changed files with 12 additions and 2 deletions

View File

@@ -15,9 +15,10 @@ _PayloadType: TypeAlias = Message | str
_EncodedPayloadType: TypeAlias = Message | bytes
_MultipartPayloadType: TypeAlias = list[_PayloadType]
_CharsetType: TypeAlias = Charset | str | None
# Type returned by Policy.header_fetch_parse, AnyOf[str | Header]
# Type returned by Policy.header_fetch_parse, often str or Header.
_HeaderType: TypeAlias = Any
_HeaderTypeParam: TypeAlias = str | Header
# Type accepted by Policy.header_store_parse.
_HeaderTypeParam: TypeAlias = str | Header | Any
class _SupportsEncodeToPayload(Protocol):
def encode(self, encoding: str, /) -> _PayloadType | _MultipartPayloadType | _SupportsDecodeToPayload: ...
@@ -25,6 +26,9 @@ class _SupportsEncodeToPayload(Protocol):
class _SupportsDecodeToPayload(Protocol):
def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ...
# TODO: This class should be generic over the header policy and/or the header
# value types allowed by the policy. This depends on PEP 696 support
# (https://github.com/python/typeshed/issues/11422).
class Message:
policy: Policy # undocumented
preamble: str | None