Skip to content

Conversation

@srittau
Copy link
Collaborator

@srittau srittau commented Oct 30, 2025

  • 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: #14935

* 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
class Mailbox(Generic[_MessageT]):
# Common interface for get_file() return types.
@type_check_only
class _GetFileReturn(Protocol[_AnyStr]):
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant