Skip to content

Commit 7cb4fe0

Browse files
authored
Bump imaplib to 3.14 (#14022)
1 parent a32af68 commit 7cb4fe0

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ fractions.Fraction.from_number
8787
gzip.GzipFile.readinto
8888
gzip.GzipFile.readinto1
8989
gzip.compress
90-
imaplib.IMAP4.file
91-
imaplib.IMAP4.idle
92-
imaplib.IMAP4_SSL.file
93-
imaplib.IMAP4_stream.file
9490
importlib.abc.ResourceReader
9591
importlib.abc.Traversable
9692
importlib.abc.TraversableResources

stdlib/imaplib.pyi

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import subprocess
22
import sys
33
import time
4-
from _typeshed import ReadableBuffer, SizedBuffer
4+
from _typeshed import ReadableBuffer, SizedBuffer, Unused
55
from builtins import list as _list # conflicts with a method named "list"
6-
from collections.abc import Callable
6+
from collections.abc import Callable, Generator
77
from datetime import datetime
88
from re import Pattern
99
from socket import socket as _socket
1010
from ssl import SSLContext, SSLSocket
1111
from types import TracebackType
1212
from typing import IO, Any, Literal, SupportsAbs, SupportsInt
13-
from typing_extensions import Self, TypeAlias
13+
from typing_extensions import Self, TypeAlias, deprecated
1414

1515
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"]
1616

@@ -42,11 +42,17 @@ class IMAP4:
4242
PROTOCOL_VERSION: str
4343
def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
4444
def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
45+
if sys.version_info >= (3, 14):
46+
@property
47+
@deprecated("IMAP4.file is unsupported, can cause errors, and may be removed.")
48+
def file(self) -> IO[str] | IO[bytes]: ...
49+
else:
50+
file: IO[str] | IO[bytes]
51+
4552
def __getattr__(self, attr: str) -> Any: ...
4653
host: str
4754
port: int
4855
sock: _socket
49-
file: IO[str] | IO[bytes]
5056
def read(self, size: int) -> bytes: ...
5157
def readline(self) -> bytes: ...
5258
def send(self, data: ReadableBuffer) -> None: ...
@@ -72,6 +78,9 @@ class IMAP4:
7278
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ...
7379
def getquota(self, root: str) -> _CommandResults: ...
7480
def getquotaroot(self, mailbox: str) -> _CommandResults: ...
81+
if sys.version_info >= (3, 14):
82+
def idle(self, duration: float | None = None) -> Idler: ...
83+
7584
def list(self, directory: str = '""', pattern: str = "*") -> tuple[str, _AnyResponseData]: ...
7685
def login(self, user: str, password: str) -> tuple[Literal["OK"], _list[bytes]]: ...
7786
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ...
@@ -100,6 +109,15 @@ class IMAP4:
100109
def xatom(self, name: str, *args: str) -> _CommandResults: ...
101110
def print_log(self) -> None: ...
102111

112+
if sys.version_info >= (3, 14):
113+
class Idler:
114+
def __init__(self, imap: IMAP4, duration: float | None = None) -> None: ...
115+
def __enter__(self) -> Self: ...
116+
def __exit__(self, exc_type: object, exc_val: Unused, exc_tb: Unused) -> Literal[False]: ...
117+
def __iter__(self) -> Self: ...
118+
def __next__(self) -> tuple[str, float | None]: ...
119+
def burst(self, interval: float = 0.1) -> Generator[tuple[str, float | None]]: ...
120+
103121
class IMAP4_SSL(IMAP4):
104122
if sys.version_info < (3, 12):
105123
keyfile: str
@@ -119,14 +137,25 @@ class IMAP4_SSL(IMAP4):
119137
timeout: float | None = None,
120138
) -> None: ...
121139
sslobj: SSLSocket
122-
file: IO[Any]
140+
if sys.version_info >= (3, 14):
141+
@property
142+
@deprecated("IMAP4_SSL.file is unsupported, can cause errors, and may be removed.")
143+
def file(self) -> IO[Any]: ...
144+
else:
145+
file: IO[Any]
146+
123147
def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ...
124148
def ssl(self) -> SSLSocket: ...
125149

126150
class IMAP4_stream(IMAP4):
127151
command: str
128152
def __init__(self, command: str) -> None: ...
129-
file: IO[Any]
153+
if sys.version_info >= (3, 14):
154+
@property
155+
@deprecated("IMAP4_stream.file is unsupported, can cause errors, and may be removed.")
156+
def file(self) -> IO[Any]: ...
157+
else:
158+
file: IO[Any]
130159
process: subprocess.Popen[bytes]
131160
writefile: IO[Any]
132161
readfile: IO[Any]

0 commit comments

Comments
 (0)