Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
_ProxyFile is no longer generic
  • Loading branch information
srittau committed Nov 3, 2025
commit 0d941e2b38a4c1010435f2b0722ef2770fae1672
34 changes: 17 additions & 17 deletions stdlib/mailbox.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsItems, SupportsNoArgReadline, SupportsRea
from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from types import GenericAlias, TracebackType
from typing import Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias

__all__ = [
Expand All @@ -29,7 +29,6 @@ __all__ = [
]

_T = TypeVar("_T")
_AnyStr = TypeVar("_AnyStr", str, bytes, default=bytes)

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

# Common interface for get_file() return types.
@type_check_only
class _GetFileReturn(Protocol[_AnyStr]):
def __iter__(self) -> Iterator[_AnyStr]: ...
class _GetFileReturn(Protocol):
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /
) -> bool | None: ...
def read(self, size: int | None = None, /) -> _AnyStr: ...
def read1(self, size: int | None = None, /) -> _AnyStr: ...
def readline(self, size: int | None = None, /) -> _AnyStr: ...
def readlines(self, sizehint: int | None = None, /) -> list[_AnyStr]: ...
def read(self, size: int | None = None, /) -> bytes: ...
def read1(self, size: int | None = None, /) -> bytes: ...
def readline(self, size: int | None = None, /) -> bytes: ...
def readlines(self, sizehint: int | None = None, /) -> list[bytes]: ...
def tell(self) -> int: ...
def seek(self, offset: int, whence: int = 0, /) -> object: ...
def close(self) -> object: ...
Expand Down Expand Up @@ -265,13 +264,14 @@ class BabylMessage(Message):

class MMDFMessage(_mboxMMDFMessage): ...

class _ProxyFile(Generic[AnyStr]):
def __init__(self, f: _GetFileReturn[AnyStr], pos: int | None = None) -> None: ...
def read(self, size: int | None = None) -> AnyStr: ...
def read1(self, size: int | None = None) -> AnyStr: ...
def readline(self, size: int | None = None) -> AnyStr: ...
def readlines(self, sizehint: int | None = None) -> list[AnyStr]: ...
def __iter__(self) -> Iterator[AnyStr]: ...
# Until Python 3.14, this class was technically - but unnecessarily - generic at runtime.
class _ProxyFile:
def __init__(self, f: _GetFileReturn, pos: int | None = None) -> None: ...
def read(self, size: int | None = None) -> bytes: ...
def read1(self, size: int | None = None) -> bytes: ...
def readline(self, size: int | None = None) -> bytes: ...
def readlines(self, sizehint: int | None = None) -> list[bytes]: ...
def __iter__(self) -> Iterator[bytes]: ...
def tell(self) -> int: ...
def seek(self, offset: int, whence: int = 0) -> None: ...
def close(self) -> None: ...
Expand All @@ -285,8 +285,8 @@ class _ProxyFile(Generic[AnyStr]):
def closed(self) -> bool: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

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

class Error(Exception): ...
class NoSuchMailboxError(Error): ...
Expand Down
Loading