Skip to content

Commit 0d941e2

Browse files
committed
_ProxyFile is no longer generic
See python/cpython#140838
1 parent 7e1843d commit 0d941e2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

stdlib/mailbox.pyi

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsItems, SupportsNoArgReadline, SupportsRea
55
from abc import ABCMeta, abstractmethod
66
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
77
from types import GenericAlias, TracebackType
8-
from typing import Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload, type_check_only
8+
from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
99
from typing_extensions import Self, TypeAlias
1010

1111
__all__ = [
@@ -29,7 +29,6 @@ __all__ = [
2929
]
3030

3131
_T = TypeVar("_T")
32-
_AnyStr = TypeVar("_AnyStr", str, bytes, default=bytes)
3332

3433
@type_check_only
3534
class _SupportsReadAndReadline(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ...
@@ -48,16 +47,16 @@ linesep: bytes
4847

4948
# Common interface for get_file() return types.
5049
@type_check_only
51-
class _GetFileReturn(Protocol[_AnyStr]):
52-
def __iter__(self) -> Iterator[_AnyStr]: ...
50+
class _GetFileReturn(Protocol):
51+
def __iter__(self) -> Iterator[bytes]: ...
5352
def __enter__(self) -> Self: ...
5453
def __exit__(
5554
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /
5655
) -> bool | None: ...
57-
def read(self, size: int | None = None, /) -> _AnyStr: ...
58-
def read1(self, size: int | None = None, /) -> _AnyStr: ...
59-
def readline(self, size: int | None = None, /) -> _AnyStr: ...
60-
def readlines(self, sizehint: int | None = None, /) -> list[_AnyStr]: ...
56+
def read(self, size: int | None = None, /) -> bytes: ...
57+
def read1(self, size: int | None = None, /) -> bytes: ...
58+
def readline(self, size: int | None = None, /) -> bytes: ...
59+
def readlines(self, sizehint: int | None = None, /) -> list[bytes]: ...
6160
def tell(self) -> int: ...
6261
def seek(self, offset: int, whence: int = 0, /) -> object: ...
6362
def close(self) -> object: ...
@@ -265,13 +264,14 @@ class BabylMessage(Message):
265264

266265
class MMDFMessage(_mboxMMDFMessage): ...
267266

268-
class _ProxyFile(Generic[AnyStr]):
269-
def __init__(self, f: _GetFileReturn[AnyStr], pos: int | None = None) -> None: ...
270-
def read(self, size: int | None = None) -> AnyStr: ...
271-
def read1(self, size: int | None = None) -> AnyStr: ...
272-
def readline(self, size: int | None = None) -> AnyStr: ...
273-
def readlines(self, sizehint: int | None = None) -> list[AnyStr]: ...
274-
def __iter__(self) -> Iterator[AnyStr]: ...
267+
# Until Python 3.14, this class was technically - but unnecessarily - generic at runtime.
268+
class _ProxyFile:
269+
def __init__(self, f: _GetFileReturn, pos: int | None = None) -> None: ...
270+
def read(self, size: int | None = None) -> bytes: ...
271+
def read1(self, size: int | None = None) -> bytes: ...
272+
def readline(self, size: int | None = None) -> bytes: ...
273+
def readlines(self, sizehint: int | None = None) -> list[bytes]: ...
274+
def __iter__(self) -> Iterator[bytes]: ...
275275
def tell(self) -> int: ...
276276
def seek(self, offset: int, whence: int = 0) -> None: ...
277277
def close(self) -> None: ...
@@ -285,8 +285,8 @@ class _ProxyFile(Generic[AnyStr]):
285285
def closed(self) -> bool: ...
286286
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
287287

288-
class _PartialFile(_ProxyFile[AnyStr]):
289-
def __init__(self, f: _GetFileReturn[AnyStr], start: int | None = None, stop: int | None = None) -> None: ...
288+
class _PartialFile(_ProxyFile):
289+
def __init__(self, f: _GetFileReturn, start: int | None = None, stop: int | None = None) -> None: ...
290290

291291
class Error(Exception): ...
292292
class NoSuchMailboxError(Error): ...

0 commit comments

Comments
 (0)