-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Various improvements for the mailbox stubs #14950
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
base: main
Are you sure you want to change the base?
Conversation
* Use `_typeshed.SupportsItems` instead of custom `_HasItems` protocol. * Use a custom covariant protocol for mailbox messages. * Add `Mailbox._dump_message`. * Return a protocol from abstract method `Mailbox.get_file()`. * Return concrete type `BytesIO` instead of `typing.IO` from `Babyl.get_file()`. * Use our custom protocol instead of semi-protocol `typing.IO` in the remaining cases. Closes: python#14935
stdlib/mailbox.pyi
Outdated
| class Mailbox(Generic[_MessageT]): | ||
| # Common interface for get_file() return types. | ||
| @type_check_only | ||
| class _GetFileReturn(Protocol[_AnyStr]): |
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.
This protocol is only generic, because _ProxyFile (and _PartialFile) are unnecessarily generic at runtime.
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.
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 was changed upstream, I removed the generic marker here and for _ProxyFile, even if the latter was technically generic up until Python 3.14.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
_typeshed.SupportsItemsinstead of custom_HasItemsprotocol.Mailbox._dump_message.Mailbox.get_file().BytesIOinstead oftyping.IOfromBabyl.get_file().typing.IOin the remaining cases.Closes: #14935