From 361b090c8943e6d9fa69da76e76f1fd8f5ac2493 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 28 Oct 2022 23:33:02 +0300 Subject: [PATCH 1/5] imaplib: fix bytes usage --- stdlib/imaplib.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index bd3d0777db15..7f8b21c2c803 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,7 +1,7 @@ import subprocess import sys import time -from _typeshed import Self +from _typeshed import Self, ReadableBuffer from builtins import list as _list # conflicts with a method named "list" from collections.abc import Callable from datetime import datetime @@ -54,12 +54,12 @@ class IMAP4: file: IO[str] | IO[bytes] def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... - def send(self, data: bytes) -> None: ... + def send(self, data: ReadableBuffer) -> None: ... def shutdown(self) -> None: ... def socket(self) -> _socket: ... def recent(self) -> _CommandResults: ... def response(self, code: str) -> _CommandResults: ... - def append(self, mailbox: str, flags: str, date_time: str, message: bytes) -> str: ... + def append(self, mailbox: str, flags: str, date_time: str, message: ReadableBuffer) -> str: ... def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> tuple[str, str]: ... def capability(self) -> _CommandResults: ... def check(self) -> _CommandResults: ... @@ -157,7 +157,7 @@ class _Authenticator: def encode(self, inp: bytes) -> str: ... def decode(self, inp: str) -> bytes: ... -def Internaldate2tuple(resp: bytes) -> time.struct_time: ... +def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time: ... def Int2AP(num: int) -> str: ... -def ParseFlags(resp: bytes) -> tuple[bytes, ...]: ... +def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | time._TimeTuple | datetime | str) -> str: ... From f584f9618ec7bba12b5d21658664a6cf4e049f82 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 28 Oct 2022 23:34:44 +0300 Subject: [PATCH 2/5] Add `None` --- stdlib/imaplib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 7f8b21c2c803..7c290c8771d6 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -157,7 +157,7 @@ class _Authenticator: def encode(self, inp: bytes) -> str: ... def decode(self, inp: str) -> bytes: ... -def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time: ... +def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time | None: ... def Int2AP(num: int) -> str: ... def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | time._TimeTuple | datetime | str) -> str: ... From 73c682b3fe65cebd6c4b6c4acd604081d9827661 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Oct 2022 20:38:11 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/imaplib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 7c290c8771d6..ada6ba3570c8 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,7 +1,7 @@ import subprocess import sys import time -from _typeshed import Self, ReadableBuffer +from _typeshed import ReadableBuffer, Self from builtins import list as _list # conflicts with a method named "list" from collections.abc import Callable from datetime import datetime From 5024d55eefbef5796b6830eb0425f72fe385b78e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 28 Oct 2022 23:47:23 +0300 Subject: [PATCH 4/5] Change Int2AP --- stdlib/imaplib.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index ada6ba3570c8..1a4098468af7 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -9,7 +9,7 @@ from re import Pattern from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any +from typing import IO, Any, SupportsAbs, SupportsInt from typing_extensions import Literal, TypeAlias __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] @@ -158,6 +158,6 @@ class _Authenticator: def decode(self, inp: str) -> bytes: ... def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time | None: ... -def Int2AP(num: int) -> str: ... +def Int2AP(num: SupportsAbs[SupportsInt]) -> str: ... def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | time._TimeTuple | datetime | str) -> str: ... From aa4a12c1e86b85c339ac9a98271369f1767f3b17 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 28 Oct 2022 23:53:27 +0300 Subject: [PATCH 5/5] Update imaplib.pyi --- stdlib/imaplib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 1a4098468af7..54760dd036ca 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -158,6 +158,6 @@ class _Authenticator: def decode(self, inp: str) -> bytes: ... def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time | None: ... -def Int2AP(num: SupportsAbs[SupportsInt]) -> str: ... +def Int2AP(num: SupportsAbs[SupportsInt]) -> bytes: ... def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | time._TimeTuple | datetime | str) -> str: ...