-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
email.message: Allow any header value #11574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,16 +15,20 @@ _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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is used exclusively for parameters/assignement, should it be
Suggested change
eh, I think that's sufficiant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
|
||||||
class _SupportsEncodeToPayload(Protocol): | ||||||
def encode(self, encoding: str, /) -> _PayloadType | _MultipartPayloadType | _SupportsDecodeToPayload: ... | ||||||
|
||||||
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 | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from email.headerregistry import Address | ||
from email.message import EmailMessage | ||
|
||
msg = EmailMessage() | ||
msg["To"] = "receiver@example.com" | ||
msg["From"] = Address("Sender Name", "sender", "example.com") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the complex payload type from
get_payload
the issue for #11095 (comment) ? (which I don't think is concerned with the header type)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no idea why I though this was the issue. Still, this PR fixes another issue.