10000 email.message: Allow any header value by srittau · Pull Request #11574 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

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

< 10000 /details>
Merged
merged 1 commit into from
Mar 11, 2024
Merged

Conversation

srittau
Copy link
Collaborator
@srittau srittau commented Mar 11, 2024

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 defaults become available.

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.
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
Copy link
Collaborator Author
srittau commented Mar 11, 2024

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
Copy link
Collaborator

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)

Copy link
Collaborator Author

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
Copy link
Collaborator
@Avasam Avasam Mar 11, 2024

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

Suggested change
_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

Copy link
Collaborator Author

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.

@Avasam
Copy link
Collaborator
Avasam commented Mar 11, 2024

Thanks! I don't see this PR introducing any new potential issues for users. Seems safe to merge.

@Avasam Avasam merged commit 4c5c576 into python:main Mar 11, 2024
@srittau srittau deleted the mail-headers branch March 11, 2024 21:59
@srittau srittau added priority: regression Something that worked before doesn't work anymore stubs: false positive Type checkers report false errors labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: regression Something that worked before doesn't work anymore stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0