-
-
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
Conversation
The allowed value depends on the used policy. For example, `EmailPolicy` allows objects with a `name` attribute, which the compat policy does not allow. This can be improved in the future, especially when TypeVar default become available.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Fixes a regression introduced in #11095. |
_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 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.
_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 comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is used exclusively for parameters/assignement, should it be
_HeaderTypeParam: TypeAlias = str | Header | Any | |
_HeaderTypeParam: TypeAlias = str | Header | object |
Either way maybe also with a comment explaining the use of a redundant union here (even if it's just "read TODO on Message
")
often str or Header.
eh, I think that's sufficiant
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.
object
wouldn't be correct, as it would imply that all values are correct, which isn't the case. We just can't express the accepted type properly.
Thanks! I don't see this PR introducing any new potential issues for users. Seems safe to merge. |
The allowed value depends on the used policy. For example,
EmailPolicy
allows objects with aname
attribute, which thecompat policy does not allow.
This can be improved in the future, especially when TypeVar defaults become available.