[stdlib] Deprecate old functions (#14553)

* [stdlib] Deprecate many functions

* Fix typo

* Imporove message for asyncio/trsock

* Apply suggestions from code review

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* Add Python before version

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Wrap comment lines

* fix the rest

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Semyon Moroz
2025-08-10 21:27:35 +00:00
committed by GitHub
parent 91ba0da4aa
commit fb0940e6c1
27 changed files with 163 additions and 34 deletions
+2 -1
View File
@@ -1,7 +1,7 @@
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar, overload
from typing_extensions import ParamSpec, TypeGuard, TypeIs
from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 11):
@@ -14,6 +14,7 @@ _FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
_P = ParamSpec("_P")
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `async def` instead.")
def coroutine(func: _FunctionT) -> _FunctionT: ...
@overload
+30 -1
View File
@@ -5,7 +5,7 @@ from builtins import type as Type # alias to avoid name clashes with property n
from collections.abc import Iterable
from types import TracebackType
from typing import Any, BinaryIO, NoReturn, overload
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, deprecated
# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address: TypeAlias = socket._Address
@@ -42,53 +42,82 @@ class TransportSocket:
def setblocking(self, flag: bool) -> None: ...
if sys.version_info < (3, 11):
def _na(self, what: str) -> None: ...
@deprecated("Removed in Python 3.11")
def accept(self) -> tuple[socket.socket, _RetAddress]: ...
@deprecated("Removed in Python 3.11")
def connect(self, address: _Address) -> None: ...
@deprecated("Removed in Python 3.11")
def connect_ex(self, address: _Address) -> int: ...
@deprecated("Removed in Python 3.11")
def bind(self, address: _Address) -> None: ...
if sys.platform == "win32":
@deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
else:
@deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ...
@deprecated("Removed in Python 3.11")
def listen(self, backlog: int = ..., /) -> None: ...
@deprecated("Removed in Python 3.11")
def makefile(self) -> BinaryIO: ...
@deprecated("Rmoved in Python 3.11")
def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ...
@deprecated("Removed in Python 3.11")
def close(self) -> None: ...
@deprecated("Removed in Python 3.11")
def detach(self) -> int: ...
if sys.platform == "linux":
@deprecated("Removed in Python 3.11")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
) -> int: ...
else:
@deprecated("Removed in Python 3.11.")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
) -> NoReturn: ...
@deprecated("Removed in Python 3.11.")
def sendmsg(
self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., /
) -> int: ...
@overload
@deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, address: _Address) -> int: ...
@overload
@deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ...
@deprecated("Removed in Python 3.11.")
def send(self, data: ReadableBuffer, flags: int = ...) -> int: ...
@deprecated("Removed in Python 3.11.")
def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ...
@deprecated("Removed in Python 3.11.")
def set_inheritable(self, inheritable: bool) -> None: ...
if sys.platform == "win32":
@deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> bytes: ...
else:
@deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> NoReturn: ...
@deprecated("Removed in Python 3.11.")
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
@deprecated("Removed in Python 3.11.")
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ...
@deprecated("Removed in Python 3.11.")
def recvmsg_into(
self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., /
) -> tuple[int, list[_CMSG], int, Any]: ...
@deprecated("Removed in Python 3.11.")
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ...
@deprecated("Removed in Python 3.11.")
def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ...
@deprecated("Removed in Python 3.11.")
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
@deprecated("Removed in Python 3.11.")
def __enter__(self) -> socket.socket: ...
@deprecated("Removed in Python 3.11.")
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...