From 56688240a132b47579d4bad72253b0391b9925fa Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Tue, 26 Nov 2019 05:45:53 +0200 Subject: [PATCH] mailbox: Fix signature of Mailbox.update method (#3493) The `update` method calls `self[key] = message` for each `(key, message)` pair so it also accepts all the same message types as the `__setitem__` method. Fix the signature so that the inputs are not restricted to `Message` instances or to instance of the `_MessageType` type parameter, but to the more reluctant `_MessageData` type alias. --- stdlib/2and3/mailbox.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/2and3/mailbox.pyi b/stdlib/2and3/mailbox.pyi index 5745f65d1..0793f27f9 100644 --- a/stdlib/2and3/mailbox.pyi +++ b/stdlib/2and3/mailbox.pyi @@ -20,10 +20,10 @@ _MessageType = TypeVar("_MessageType", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] class _HasIteritems(Protocol): - def iteritems(self) -> Iterator[Tuple[str, Message]]: ... + def iteritems(self) -> Iterator[Tuple[str, _MessageData]]: ... class _HasItems(Protocol): - def items(self) -> Iterator[Tuple[str, Message]]: ... + def items(self) -> Iterator[Tuple[str, _MessageData]]: ... linesep: bytes @@ -63,7 +63,7 @@ class Mailbox(Generic[_MessageType]): @overload def pop(self, key: str, default: _T = ...) -> Union[_MessageType, _T]: ... def popitem(self) -> Tuple[str, _MessageType]: ... - def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageType]]]] = ...) -> None: ... + def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ... def flush(self) -> None: ... def lock(self) -> None: ... def unlock(self) -> None: ...