From 26d42f0ebb7215f517e0dd7a03fc8619cfa5cc6a Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 10 Aug 2025 18:24:50 +0400 Subject: [PATCH 1/8] [stdlib] Deprecate many functions --- stdlib/_frozen_importlib.pyi | 5 +++++ stdlib/_frozen_importlib_external.pyi | 8 ++++--- stdlib/_ssl.pyi | 3 ++- stdlib/_tkinter.pyi | 3 ++- stdlib/ast.pyi | 6 +++-- stdlib/asyncio/coroutines.pyi | 3 ++- stdlib/asyncio/trsock.pyi | 31 +++++++++++++++++++++++++- stdlib/binascii.pyi | 6 ++++- stdlib/configparser.pyi | 3 +++ stdlib/gettext.pyi | 4 ++++ stdlib/gzip.pyi | 3 ++- stdlib/importlib/__init__.pyi | 2 ++ stdlib/importlib/_abc.pyi | 2 ++ stdlib/importlib/abc.pyi | 4 ++++ stdlib/importlib/metadata/__init__.pyi | 3 ++- stdlib/importlib/util.pyi | 5 ++++- stdlib/inspect.pyi | 5 ++++- stdlib/locale.pyi | 8 ++++++- stdlib/pathlib/__init__.pyi | 2 +- stdlib/pkgutil.pyi | 6 +++-- stdlib/pty.pyi | 4 ++-- stdlib/re.pyi | 8 +++++-- stdlib/smtpd.pyi | 3 ++- stdlib/tkinter/__init__.pyi | 1 + stdlib/turtle.pyi | 4 +++- stdlib/urllib/request.pyi | 4 ++-- stdlib/zipimport.pyi | 6 +++-- 27 files changed, 114 insertions(+), 28 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 3dbc8c6b52f0..1640edc7db14 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -6,6 +6,7 @@ from _typeshed.importlib import LoaderProtocol from collections.abc import Mapping, Sequence from types import ModuleType from typing import Any, ClassVar +from typing_extensions import deprecated # Signature of `builtins.__import__` should be kept identical to `importlib.__import__` def __import__( @@ -49,6 +50,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # MetaPathFinder if sys.version_info < (3, 12): @classmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead..") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... @classmethod @@ -67,6 +69,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # Loader if sys.version_info < (3, 12): @staticmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(module: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod @@ -83,6 +86,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder if sys.version_info < (3, 12): @classmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead..") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... @classmethod @@ -101,6 +105,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # Loader if sys.version_info < (3, 12): @staticmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(m: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index edad50a8d858..1410d35e5ad6 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -43,6 +43,7 @@ def spec_from_file_location( class WindowsRegistryFinder(importlib.abc.MetaPathFinder): if sys.version_info < (3, 12): @classmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... @classmethod @@ -70,6 +71,7 @@ class PathFinder(importlib.abc.MetaPathFinder): ) -> ModuleSpec | None: ... if sys.version_info < (3, 12): @classmethod + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... SOURCE_SUFFIXES: list[str] @@ -158,7 +160,7 @@ if sys.version_info >= (3, 11): def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... if sys.version_info < (3, 12): @staticmethod - @deprecated("module_repr() is deprecated, and has been removed in Python 3.12") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(module: types.ModuleType) -> str: ... _NamespaceLoader = NamespaceLoader @@ -176,12 +178,12 @@ else: def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info >= (3, 10): @staticmethod - @deprecated("module_repr() is deprecated, and has been removed in Python 3.12") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(module: types.ModuleType) -> str: ... def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... else: @classmethod - @deprecated("module_repr() is deprecated, and has been removed in Python 3.12") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(cls, module: types.ModuleType) -> str: ... if sys.version_info >= (3, 13): diff --git a/stdlib/_ssl.pyi b/stdlib/_ssl.pyi index a73061577965..8afa3e5297bd 100644 --- a/stdlib/_ssl.pyi +++ b/stdlib/_ssl.pyi @@ -13,7 +13,7 @@ from ssl import ( SSLZeroReturnError as SSLZeroReturnError, ) from typing import Any, ClassVar, Final, Literal, TypedDict, final, overload, type_check_only -from typing_extensions import NotRequired, Self, TypeAlias +from typing_extensions import NotRequired, Self, TypeAlias, deprecated _PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray _PCTRTT: TypeAlias = tuple[tuple[str, str], ...] @@ -51,6 +51,7 @@ def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ... def RAND_bytes(n: int, /) -> bytes: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.6; removed in Python 3.12. Use `ssl.RAND_bytes()` instead.") def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ... if sys.version_info < (3, 10): diff --git a/stdlib/_tkinter.pyi b/stdlib/_tkinter.pyi index 08eb00ca442b..2dd43fcec7a4 100644 --- a/stdlib/_tkinter.pyi +++ b/stdlib/_tkinter.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable from typing import Any, ClassVar, Final, final -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated # _tkinter is meant to be only used internally by tkinter, but some tkinter # functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl @@ -84,6 +84,7 @@ class TkappType: def record(self, script, /): ... def setvar(self, *ags, **kwargs): ... if sys.version_info < (3, 11): + @deprecated("Deprecated since python 3.9; removed in Python 3.11. Use `splitlist()` instead.") def split(self, arg, /): ... def splitlist(self, arg, /): ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 3ba56f55932a..dc58c7ee54e4 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1097,15 +1097,17 @@ class Constant(expr): kind: str | None if sys.version_info < (3, 14): # Aliases for value, for backwards compatibility - @deprecated("Will be removed in Python 3.14; use value instead") @property + @deprecated("Will be removed in Python 3.14. Use value instead.") def n(self) -> _ConstantValue: ... @n.setter + @deprecated("Will be removed in Python 3.14. Use value instead.") def n(self, value: _ConstantValue) -> None: ... - @deprecated("Will be removed in Python 3.14; use value instead") @property + @deprecated("Will be removed in Python 3.14. Use value instead.") def s(self) -> _ConstantValue: ... @s.setter + @deprecated("Will be removed in Python 3.14. Use value instead.") def s(self, value: _ConstantValue) -> None: ... def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index 8ef30b3d3198..59212f4ec398 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -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 diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index e74cf6fd4e05..67e289392ab5 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -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("Deprecated and removed in Python 3.11") def accept(self) -> tuple[socket.socket, _RetAddress]: ... + @deprecated("Deprecated and removed in Python 3.11") def connect(self, address: _Address) -> None: ... + @deprecated("Deprecated and removed in Python 3.11") def connect_ex(self, address: _Address) -> int: ... + @deprecated("Deprecated and removed in Python 3.11") def bind(self, address: _Address) -> None: ... if sys.platform == "win32": + @deprecated("Deprecated and removed in Python 3.11") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ... else: + @deprecated("Deprecated and removed in Python 3.11") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ... + @deprecated("Deprecated and removed in Python 3.11") def listen(self, backlog: int = ..., /) -> None: ... + @deprecated("Deprecated and removed in Python 3.11") def makefile(self) -> BinaryIO: ... + @deprecated("Deprecated and removed in Python 3.11") def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... + @deprecated("Deprecated and removed in Python 3.11") def close(self) -> None: ... + @deprecated("Deprecated and removed in Python 3.11") def detach(self) -> int: ... if sys.platform == "linux": + @deprecated("Deprecated and removed in Python 3.11") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... else: + @deprecated("Deprecated and removed in Python 3.11") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> NoReturn: ... + @deprecated("Deprecated and removed in Python 3.11") def sendmsg( self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., / ) -> int: ... @overload + @deprecated("Deprecated and removed in Python 3.11") def sendto(self, data: ReadableBuffer, address: _Address) -> int: ... @overload + @deprecated("Deprecated and removed in Python 3.11") def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ... + @deprecated("Deprecated and removed in Python 3.11") def send(self, data: ReadableBuffer, flags: int = ...) -> int: ... + @deprecated("Deprecated and removed in Python 3.11") def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ... + @deprecated("Deprecated and removed in Python 3.11") def set_inheritable(self, inheritable: bool) -> None: ... if sys.platform == "win32": + @deprecated("Deprecated and removed in Python 3.11") def share(self, process_id: int) -> bytes: ... else: + @deprecated("Deprecated and removed in Python 3.11") def share(self, process_id: int) -> NoReturn: ... + @deprecated("Deprecated and removed in Python 3.11") def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... + @deprecated("Deprecated and removed in Python 3.11") def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... + @deprecated("Deprecated and removed in Python 3.11") def recvmsg_into( self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., / ) -> tuple[int, list[_CMSG], int, Any]: ... + @deprecated("Deprecated and removed in Python 3.11") def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ... + @deprecated("Deprecated and removed in Python 3.11") def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... + @deprecated("Deprecated and removed in Python 3.11") def recv(self, bufsize: int, flags: int = ...) -> bytes: ... + @deprecated("Deprecated and removed in Python 3.11") def __enter__(self) -> socket.socket: ... + @deprecated("Deprecated and removed in Python 3.11") def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/binascii.pyi b/stdlib/binascii.pyi index 32e018c653cb..e09d335596fc 100644 --- a/stdlib/binascii.pyi +++ b/stdlib/binascii.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated # Many functions in binascii accept buffer objects # or ASCII-only strings. @@ -20,9 +20,13 @@ def a2b_qp(data: _AsciiBuffer, header: bool = False) -> bytes: ... def b2a_qp(data: ReadableBuffer, quotetabs: bool = False, istext: bool = True, header: bool = False) -> bytes: ... if sys.version_info < (3, 11): + @deprecated("Deprecated since Python 3.9; removed in Python 3.11.") def a2b_hqx(data: _AsciiBuffer, /) -> bytes: ... + @deprecated("Deprecated since Python 3.9; removed in Python 3.11.") def rledecode_hqx(data: ReadableBuffer, /) -> bytes: ... + @deprecated("Deprecated since Python 3.9; removed in Python 3.11.") def rlecode_hqx(data: ReadableBuffer, /) -> bytes: ... + @deprecated("Deprecated since Python 3.9; removed in Python 3.11.") def b2a_hqx(data: ReadableBuffer, /) -> bytes: ... def crc_hqx(data: ReadableBuffer, crc: int, /) -> int: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index e0992bb48dc4..b3a421003026 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -137,6 +137,9 @@ class BasicInterpolation(Interpolation): ... class ExtendedInterpolation(Interpolation): ... if sys.version_info < (3, 13): + @deprecated( + "Deprecated since Python 3.2; removed in Python 3.13. Use `BasicInterpolation` or `ExtendedInterpolation` instead." + ) class LegacyInterpolation(Interpolation): def before_get(self, parser: _Parser, section: _SectionName, option: str, value: str, vars: _Section) -> str: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index d2e6d6b61b66..937aece03437 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -44,9 +44,13 @@ class NullTranslations: def info(self) -> dict[str, str]: ... def charset(self) -> str | None: ... if sys.version_info < (3, 11): + @deprecated("Deprecated since Python 3.8; removed in Python 3.11.") def output_charset(self) -> str | None: ... + @deprecated("Deprecated since Python 3.8; removed in Python 3.11.") def set_output_charset(self, charset: str) -> None: ... + @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `gettext()` instead.") def lgettext(self, message: str) -> str: ... + @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `ngettext()` instead.") def lngettext(self, msgid1: str, msgid2: str, n: int) -> str: ... def install(self, names: Container[str] | None = None) -> None: ... diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index 06f5e2880bd5..b18f76f06e3e 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -3,7 +3,7 @@ import zlib from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO, TextIOWrapper from typing import Final, Literal, Protocol, overload, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 14): from compression._common._streams import BaseStream, DecompressReader @@ -143,6 +143,7 @@ class GzipFile(BaseStream): ) -> None: ... if sys.version_info < (3, 12): @property + @deprecated("Deprecated since Python 2.6; removed in Python 3.12. Use `name` attribute instead.") def filename(self) -> str: ... @property diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index cab81512e92f..d60f90adee19 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -2,6 +2,7 @@ import sys from importlib._bootstrap import __import__ as __import__ from importlib.abc import Loader from types import ModuleType +from typing_extensions import deprecated __all__ = ["__import__", "import_module", "invalidate_caches", "reload"] @@ -9,6 +10,7 @@ __all__ = ["__import__", "import_module", "invalidate_caches", "reload"] def import_module(name: str, package: str | None = None) -> ModuleType: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `importlib.util.find_spec()` instead.") def find_loader(name: str, path: str | None = None) -> Loader | None: ... def invalidate_caches() -> None: ... diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index 1a21b9a72cd8..e0a43f6059be 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -2,11 +2,13 @@ import sys import types from abc import ABCMeta from importlib.machinery import ModuleSpec +from typing_extensions import deprecated if sys.version_info >= (3, 10): class Loader(metaclass=ABCMeta): def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_repr(self, module: types.ModuleType) -> str: ... def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index cf0fd0807b7b..ef87663cb72d 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -37,6 +37,7 @@ else: def exec_module(self, module: types.ModuleType) -> None: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `MetaPathFinder` or `PathEntryFinder` instead.") class Finder(metaclass=ABCMeta): ... @deprecated("Deprecated as of Python 3.7: Use importlib.resources.abc.TraversableResources instead.") @@ -71,6 +72,7 @@ if sys.version_info >= (3, 10): # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol class MetaPathFinder(metaclass=ABCMeta): if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.") def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ... def invalidate_caches(self) -> None: ... @@ -81,7 +83,9 @@ if sys.version_info >= (3, 10): class PathEntryFinder(metaclass=ABCMeta): if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.") def find_module(self, fullname: str) -> Loader | None: ... + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ... def invalidate_caches(self) -> None: ... diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 6fee7d94f8a9..d1315b2eb2f1 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -11,7 +11,7 @@ from os import PathLike from pathlib import Path from re import Pattern from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing_extensions import Self, TypeAlias, deprecated _T = TypeVar("_T") _KT = TypeVar("_KT") @@ -148,6 +148,7 @@ if sys.version_info >= (3, 10) and sys.version_info < (3, 12): def keys(self) -> dict_keys[_KT, _VT]: ... def values(self) -> dict_values[_KT, _VT]: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `select` instead.") class SelectableGroups(Deprecated[str, EntryPoints], dict[str, EntryPoints]): # use as dict is deprecated since 3.10 @classmethod def load(cls, eps: Iterable[EntryPoint]) -> Self: ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 370a08623842..8f516037d1cc 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -12,13 +12,16 @@ from importlib._bootstrap_external import ( spec_from_file_location as spec_from_file_location, ) from importlib.abc import Loader -from typing_extensions import ParamSpec +from typing_extensions import ParamSpec, deprecated _P = ParamSpec("_P") if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... def resolve_name(name: str, package: str | None) -> str: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index e73f9e75838d..292e900e6e61 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -26,7 +26,7 @@ from types import ( WrapperDescriptorType, ) from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs +from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs, deprecated if sys.version_info >= (3, 14): from annotationlib import Format @@ -476,12 +476,14 @@ class Arguments(NamedTuple): def getargs(co: CodeType) -> Arguments: ... if sys.version_info < (3, 11): + @deprecated("Deprecated since Python 3.0; removed in Python 3.11.") class ArgSpec(NamedTuple): args: list[str] varargs: str | None keywords: str | None defaults: tuple[Any, ...] + @deprecated("Deprecated since Python 3.0; removed in Python 3.11. Use `inspect.signature()` instead.") def getargspec(func: object) -> ArgSpec: ... class FullArgSpec(NamedTuple): @@ -512,6 +514,7 @@ else: def formatannotationrelativeto(object: object) -> Callable[[object], str]: ... if sys.version_info < (3, 11): + @deprecated("Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and `Signature` object instead.") def formatargspec( args: list[str], varargs: str | None = None, diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 58de65449572..fae9f849b637 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -18,6 +18,7 @@ from builtins import str as _str from collections.abc import Callable, Iterable from decimal import Decimal from typing import Any +from typing_extensions import deprecated if sys.version_info >= (3, 11): from _locale import getencoding as getencoding @@ -137,9 +138,14 @@ def getpreferredencoding(do_setlocale: bool = True) -> _str: ... def normalize(localename: _str) -> _str: ... if sys.version_info < (3, 13): - def resetlocale(category: int = ...) -> None: ... + if sys.version_info >= (3, 11): + @deprecated("Deprecated since Python 3.11; removed in Python 3.13. Use `locale.setlocale(locale.LC_ALL, '')` instead.") + def resetlocale(category: int = ...) -> None: ... + else: + def resetlocale(category: int = ...) -> None: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `locale.format_string()` instead.") def format( percent: _str, value: float | Decimal, grouping: bool = False, monetary: bool = False, *additional: Any ) -> _str: ... diff --git a/stdlib/pathlib/__init__.pyi b/stdlib/pathlib/__init__.pyi index bf263f8b45a0..8c8d558b8f04 100644 --- a/stdlib/pathlib/__init__.pyi +++ b/stdlib/pathlib/__init__.pyi @@ -301,7 +301,7 @@ class Path(PurePath): def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ... if sys.version_info < (3, 12): if sys.version_info >= (3, 10): - @deprecated("Deprecated as of Python 3.10 and removed in Python 3.12. Use hardlink_to() instead.") + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use hardlink_to() instead.") def link_to(self, target: StrOrBytesPath) -> None: ... else: def link_to(self, target: StrOrBytesPath) -> None: ... diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index e764d08e79f8..6acdcb41699f 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -30,16 +30,18 @@ class ModuleInfo(NamedTuple): def extend_path(path: _PathT, name: str) -> _PathT: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `importlib` module instead.") class ImpImporter: def __init__(self, path: StrOrBytesPath | None = None) -> None: ... + @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `importlib` module instead.") class ImpLoader: def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ... if sys.version_info < (3, 14): - @deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.") + @deprecated("Deprecated and removed in Python 3.14. Use `importlib.util.find_spec()` instead.") def find_loader(fullname: str) -> LoaderProtocol | None: ... - @deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.") + @deprecated("Deprecated and removed in Python 3.14. Use `importlib.util.find_spec()` instead.") def get_loader(module_or_name: str) -> LoaderProtocol | None: ... def get_importer(path_item: StrOrBytesPath) -> PathEntryFinderProtocol | None: ... diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index 941915179c4a..87c421b97fa2 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -15,9 +15,9 @@ if sys.platform != "win32": def openpty() -> tuple[int, int]: ... if sys.version_info < (3, 14): - @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead") + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use openpty() instead.") def master_open() -> tuple[int, str]: ... - @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead") + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use openpty() instead.") def slave_open(tty_name: str) -> int: ... def fork() -> tuple[int, int]: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index b080626c5802..fb2a06d5e4c8 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -6,7 +6,7 @@ from _typeshed import MaybeNone, ReadableBuffer from collections.abc import Callable, Iterator, Mapping from types import GenericAlias from typing import Any, AnyStr, Final, Generic, Literal, TypeVar, final, overload -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated __all__ = [ "match", @@ -307,4 +307,8 @@ def escape(pattern: AnyStr) -> AnyStr: ... def purge() -> None: ... if sys.version_info < (3, 13): - def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ... + if sys.version_info >= (3, 11): + @deprecated("Deprecated since Python 3.11; removed in Python 3.13. Use `re.compile()` instead.") + def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ... # undocumented + else: + def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ... # undocumented diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index 7392bd51627d..dee7e949f42f 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -4,7 +4,7 @@ import socket import sys from collections import defaultdict from typing import Any -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 11): __all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy"] @@ -87,5 +87,6 @@ class PureProxy(SMTPServer): def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[str], data: bytes | str) -> str | None: ... # type: ignore[override] if sys.version_info < (3, 11): + @deprecated("Deprecated since Python 3.9; removed in Python 3.11.") class MailmanProxy(PureProxy): def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[str], data: bytes | str) -> str | None: ... # type: ignore[override] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index b802d5e97c84..4cb532724626 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1029,6 +1029,7 @@ class Tk(Misc, Wm): def loadtk(self) -> None: ... def record(self, script, /): ... if sys.version_info < (3, 11): + @deprecated("Deprecated since python 3.9; removed in Python 3.11. Use `splitlist()` instead.") def split(self, arg, /): ... def splitlist(self, arg, /): ... diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 7d39026b8041..32915c5788f6 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -4,7 +4,7 @@ from collections.abc import Callable, Generator, Sequence from contextlib import contextmanager from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "ScrolledCanvas", @@ -426,6 +426,7 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods def get_shapepoly(self) -> _PolygonCoords | None: ... if sys.version_info < (3, 13): + @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead") def settiltangle(self, angle: float) -> None: ... @overload @@ -707,6 +708,7 @@ def shapetransform( def get_shapepoly() -> _PolygonCoords | None: ... if sys.version_info < (3, 13): + @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead") def settiltangle(angle: float) -> None: ... @overload diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index b99577c1cf71..b111bfd51ee3 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -325,7 +325,7 @@ def urlretrieve( def urlcleanup() -> None: ... if sys.version_info < (3, 14): - @deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer urlopen functions and methods.") class URLopener: version: ClassVar[str] def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ... @@ -356,7 +356,7 @@ if sys.version_info < (3, 14): def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented def __del__(self) -> None: ... - @deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer urlopen functions and methods.") class FancyURLopener(URLopener): def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ... def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 4aab318e7c71..6da7513f7e80 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -27,7 +27,9 @@ class zipimporter(_LoaderBasics): def __init__(self, path: StrOrBytesPath) -> None: ... if sys.version_info < (3, 12): - def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... # undocumented + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... @@ -42,7 +44,7 @@ class zipimporter(_LoaderBasics): def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... - @deprecated("Deprecated since 3.10; use exec_module() instead") + @deprecated("Deprecated since Python 3.10; use `exec_module()` instead.") def load_module(self, fullname: str) -> ModuleType: ... if sys.version_info >= (3, 10): def exec_module(self, module: ModuleType) -> None: ... From 9cf0cd0878f8eda168cc2ceccf670a1ec62d406e Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 10 Aug 2025 21:45:02 +0400 Subject: [PATCH 2/8] Fix typo --- stdlib/_frozen_importlib.pyi | 4 +-- stdlib/_tkinter.pyi | 2 +- stdlib/asyncio/trsock.pyi | 58 ++++++++++++++++++------------------ stdlib/pkgutil.pyi | 12 +++++--- stdlib/pty.pyi | 12 +++++--- stdlib/tkinter/__init__.pyi | 2 +- stdlib/turtle.pyi | 4 +-- stdlib/zipimport.pyi | 18 +++++++---- 8 files changed, 63 insertions(+), 49 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 1640edc7db14..7eb8634c4842 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -50,7 +50,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # MetaPathFinder if sys.version_info < (3, 12): @classmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead..") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... @classmethod @@ -86,7 +86,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder if sys.version_info < (3, 12): @classmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead..") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... @classmethod diff --git a/stdlib/_tkinter.pyi b/stdlib/_tkinter.pyi index 2dd43fcec7a4..46366ccc1740 100644 --- a/stdlib/_tkinter.pyi +++ b/stdlib/_tkinter.pyi @@ -84,7 +84,7 @@ class TkappType: def record(self, script, /): ... def setvar(self, *ags, **kwargs): ... if sys.version_info < (3, 11): - @deprecated("Deprecated since python 3.9; removed in Python 3.11. Use `splitlist()` instead.") + @deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.") def split(self, arg, /): ... def splitlist(self, arg, /): ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 67e289392ab5..b4683ca4ee79 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -42,82 +42,82 @@ class TransportSocket: def setblocking(self, flag: bool) -> None: ... if sys.version_info < (3, 11): def _na(self, what: str) -> None: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def accept(self) -> tuple[socket.socket, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def connect(self, address: _Address) -> None: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def connect_ex(self, address: _Address) -> int: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def bind(self, address: _Address) -> None: ... if sys.platform == "win32": - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ... else: - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def listen(self, backlog: int = ..., /) -> None: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def makefile(self) -> BinaryIO: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def close(self) -> None: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def detach(self) -> int: ... if sys.platform == "linux": - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... else: - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendmsg( self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., / ) -> int: ... @overload - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendto(self, data: ReadableBuffer, address: _Address) -> int: ... @overload - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def send(self, data: ReadableBuffer, flags: int = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def set_inheritable(self, inheritable: bool) -> None: ... if sys.platform == "win32": - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def share(self, process_id: int) -> bytes: ... else: - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def share(self, process_id: int) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recvmsg_into( self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., / ) -> tuple[int, list[_CMSG], int, Any]: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def __enter__(self) -> socket.socket: ... - @deprecated("Deprecated and removed in Python 3.11") + @deprecated("Deprecated and removed in Python 3.11.") def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 6acdcb41699f..bfe893d9bdaf 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -39,10 +39,14 @@ if sys.version_info < (3, 12): def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ... if sys.version_info < (3, 14): - @deprecated("Deprecated and removed in Python 3.14. Use `importlib.util.find_spec()` instead.") - def find_loader(fullname: str) -> LoaderProtocol | None: ... - @deprecated("Deprecated and removed in Python 3.14. Use `importlib.util.find_spec()` instead.") - def get_loader(module_or_name: str) -> LoaderProtocol | None: ... + if sys.version_info >= (3, 12): + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `importlib.util.find_spec()` instead.") + def find_loader(fullname: str) -> LoaderProtocol | None: ... + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `importlib.util.find_spec()` instead.") + def get_loader(module_or_name: str) -> LoaderProtocol | None: ... + else: + def find_loader(fullname: str) -> LoaderProtocol | None: ... + def get_loader(module_or_name: str) -> LoaderProtocol | None: ... def get_importer(path_item: StrOrBytesPath) -> PathEntryFinderProtocol | None: ... def iter_importers(fullname: str = "") -> Iterator[MetaPathFinderProtocol | PathEntryFinderProtocol]: ... diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index 87c421b97fa2..d1c78f9e3dd6 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -15,10 +15,14 @@ if sys.platform != "win32": def openpty() -> tuple[int, int]: ... if sys.version_info < (3, 14): - @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use openpty() instead.") - def master_open() -> tuple[int, str]: ... - @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use openpty() instead.") - def slave_open(tty_name: str) -> int: ... + if sys.version_info >= (3, 12): + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `openpty()` instead.") + def master_open() -> tuple[int, str]: ... + @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `openpty()` instead.") + def slave_open(tty_name: str) -> int: ... + else: + def master_open() -> tuple[int, str]: ... + def slave_open(tty_name: str) -> int: ... def fork() -> tuple[int, int]: ... def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 4cb532724626..76b2ddcf17df 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1029,7 +1029,7 @@ class Tk(Misc, Wm): def loadtk(self) -> None: ... def record(self, script, /): ... if sys.version_info < (3, 11): - @deprecated("Deprecated since python 3.9; removed in Python 3.11. Use `splitlist()` instead.") + @deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.") def split(self, arg, /): ... def splitlist(self, arg, /): ... diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 32915c5788f6..e41476b73b8c 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -426,7 +426,7 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods def get_shapepoly(self) -> _PolygonCoords | None: ... if sys.version_info < (3, 13): - @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead") + @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.") def settiltangle(self, angle: float) -> None: ... @overload @@ -708,7 +708,7 @@ def shapetransform( def get_shapepoly() -> _PolygonCoords | None: ... if sys.version_info < (3, 13): - @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead") + @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.") def settiltangle(angle: float) -> None: ... @overload diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 6da7513f7e80..22af3c272759 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -27,10 +27,14 @@ class zipimporter(_LoaderBasics): def __init__(self, path: StrOrBytesPath) -> None: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... + else: + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> bytes: ... @@ -44,10 +48,12 @@ class zipimporter(_LoaderBasics): def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... - @deprecated("Deprecated since Python 3.10; use `exec_module()` instead.") - def load_module(self, fullname: str) -> ModuleType: ... if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> ModuleType: ... def exec_module(self, module: ModuleType) -> None: ... def create_module(self, spec: ModuleSpec) -> None: ... def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ... def invalidate_caches(self) -> None: ... + else: + def load_module(self, fullname: str) -> ModuleType: ... From f18573367f9e7494051201532b4b67bca73a7dd7 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 10 Aug 2025 21:48:41 +0400 Subject: [PATCH 3/8] Imporove message for asyncio/trsock --- stdlib/asyncio/trsock.pyi | 58 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index b4683ca4ee79..d5be8c26d919 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -42,82 +42,82 @@ class TransportSocket: def setblocking(self, flag: bool) -> None: ... if sys.version_info < (3, 11): def _na(self, what: str) -> None: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def accept(self) -> tuple[socket.socket, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def connect(self, address: _Address) -> None: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def connect_ex(self, address: _Address) -> int: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def bind(self, address: _Address) -> None: ... if sys.platform == "win32": - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ... else: - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def listen(self, backlog: int = ..., /) -> None: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def makefile(self) -> BinaryIO: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def close(self) -> None: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def detach(self) -> int: ... if sys.platform == "linux": - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... else: - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendmsg( self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., / ) -> int: ... @overload - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendto(self, data: ReadableBuffer, address: _Address) -> int: ... @overload - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def send(self, data: ReadableBuffer, flags: int = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def set_inheritable(self, inheritable: bool) -> None: ... if sys.platform == "win32": - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def share(self, process_id: int) -> bytes: ... else: - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def share(self, process_id: int) -> NoReturn: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recvmsg_into( self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., / ) -> tuple[int, list[_CMSG], int, Any]: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def __enter__(self) -> socket.socket: ... - @deprecated("Deprecated and removed in Python 3.11.") + @deprecated("Initially it was deprecated; removed in Python 3.11.") def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... From ebc9644479925ebf244215f3d638b2a8111594f9 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Sun, 10 Aug 2025 20:52:02 +0000 Subject: [PATCH 4/8] Apply suggestions from code review Co-authored-by: Alex Waygood --- stdlib/_frozen_importlib.pyi | 4 ++-- stdlib/_frozen_importlib_external.pyi | 6 +++--- stdlib/ast.pyi | 8 ++++---- stdlib/asyncio/trsock.pyi | 24 ++++++++++++------------ stdlib/importlib/_abc.pyi | 2 +- stdlib/inspect.pyi | 2 +- stdlib/pathlib/__init__.pyi | 2 +- stdlib/pkgutil.pyi | 4 ++-- stdlib/urllib/request.pyi | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 7eb8634c4842..4140fed44c91 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -69,7 +69,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # Loader if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(module: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod @@ -105,7 +105,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # Loader if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(m: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index 1410d35e5ad6..745b1700ee7e 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -160,7 +160,7 @@ if sys.version_info >= (3, 11): def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(module: types.ModuleType) -> str: ... _NamespaceLoader = NamespaceLoader @@ -178,12 +178,12 @@ else: def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info >= (3, 10): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(module: types.ModuleType) -> str: ... def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... else: @classmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(cls, module: types.ModuleType) -> str: ... if sys.version_info >= (3, 13): diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index dc58c7ee54e4..8ee867116301 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1098,16 +1098,16 @@ class Constant(expr): if sys.version_info < (3, 14): # Aliases for value, for backwards compatibility @property - @deprecated("Will be removed in Python 3.14. Use value instead.") + @deprecated("Will be removed in Python 3.14. Use `value` instead.") def n(self) -> _ConstantValue: ... @n.setter - @deprecated("Will be removed in Python 3.14. Use value instead.") + @deprecated("Will be removed in Python 3.14. Use `value` instead.") def n(self, value: _ConstantValue) -> None: ... @property - @deprecated("Will be removed in Python 3.14. Use value instead.") + @deprecated("Will be removed in Python 3.14. Use `value` instead.") def s(self) -> _ConstantValue: ... @s.setter - @deprecated("Will be removed in Python 3.14. Use value instead.") + @deprecated("Will be removed in Python 3.14. Use `value` instead.") def s(self, value: _ConstantValue) -> None: ... def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index d5be8c26d919..7d8ed6d48836 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -42,33 +42,33 @@ class TransportSocket: def setblocking(self, flag: bool) -> None: ... if sys.version_info < (3, 11): def _na(self, what: str) -> None: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def accept(self) -> tuple[socket.socket, _RetAddress]: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def connect(self, address: _Address) -> None: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def connect_ex(self, address: _Address) -> int: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def bind(self, address: _Address) -> None: ... if sys.platform == "win32": - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ... else: - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def listen(self, backlog: int = ..., /) -> None: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def makefile(self) -> BinaryIO: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Rmoved in Python 3.11") def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def close(self) -> None: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def detach(self) -> int: ... if sys.platform == "linux": - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index e0a43f6059be..f0342aa02be3 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -8,7 +8,7 @@ if sys.version_info >= (3, 10): class Loader(metaclass=ABCMeta): def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") def module_repr(self, module: types.ModuleType) -> str: ... def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 292e900e6e61..620e9ca221c7 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -514,7 +514,7 @@ else: def formatannotationrelativeto(object: object) -> Callable[[object], str]: ... if sys.version_info < (3, 11): - @deprecated("Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and `Signature` object instead.") + @deprecated("Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and the `Signature` class instead.") def formatargspec( args: list[str], varargs: str | None = None, diff --git a/stdlib/pathlib/__init__.pyi b/stdlib/pathlib/__init__.pyi index 8c8d558b8f04..4858f8db1ed0 100644 --- a/stdlib/pathlib/__init__.pyi +++ b/stdlib/pathlib/__init__.pyi @@ -301,7 +301,7 @@ class Path(PurePath): def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ... if sys.version_info < (3, 12): if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use hardlink_to() instead.") + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") def link_to(self, target: StrOrBytesPath) -> None: ... else: def link_to(self, target: StrOrBytesPath) -> None: ... diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index bfe893d9bdaf..7c70dcc4c5ab 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -30,11 +30,11 @@ class ModuleInfo(NamedTuple): def extend_path(path: _PathT, name: str) -> _PathT: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `importlib` module instead.") + @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use the `importlib` module instead.") class ImpImporter: def __init__(self, path: StrOrBytesPath | None = None) -> None: ... - @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `importlib` module instead.") + @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use the `importlib` module instead.") class ImpLoader: def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ... diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index b111bfd51ee3..35f4d47a5599 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -325,7 +325,7 @@ def urlretrieve( def urlcleanup() -> None: ... if sys.version_info < (3, 14): - @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer urlopen functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer `urlopen` functions and methods.") class URLopener: version: ClassVar[str] def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ... @@ -356,7 +356,7 @@ if sys.version_info < (3, 14): def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented def __del__(self) -> None: ... - @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer urlopen functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer `urlopen` functions and methods.") class FancyURLopener(URLopener): def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ... def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented From 987fbaeb3bc81ed3fc26446ccf99892f44fd2741 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 11 Aug 2025 00:53:51 +0400 Subject: [PATCH 5/8] Add Python before version --- stdlib/urllib/request.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 35f4d47a5599..876b9d3f165c 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -325,7 +325,7 @@ def urlretrieve( def urlcleanup() -> None: ... if sys.version_info < (3, 14): - @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer `urlopen` functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in Python 3.14. Use newer `urlopen` functions and methods.") class URLopener: version: ClassVar[str] def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ... @@ -356,7 +356,7 @@ if sys.version_info < (3, 14): def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented def __del__(self) -> None: ... - @deprecated("Deprecated since Python 3.3; removed in 3.14. Use newer `urlopen` functions and methods.") + @deprecated("Deprecated since Python 3.3; removed in Python 3.14. Use newer `urlopen` functions and methods.") class FancyURLopener(URLopener): def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ... def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented From 4f56a7a0d93ab245c3572f288e15e89851a92414 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Aug 2025 20:53:44 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_frozen_importlib.pyi | 8 ++++++-- stdlib/_frozen_importlib_external.pyi | 12 +++++++++--- stdlib/importlib/_abc.pyi | 4 +++- stdlib/inspect.pyi | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 4140fed44c91..1e34376e4613 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -69,7 +69,9 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # Loader if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(module: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod @@ -105,7 +107,9 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # Loader if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(m: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @staticmethod diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index 745b1700ee7e..81d5ee814137 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -160,7 +160,9 @@ if sys.version_info >= (3, 11): def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... if sys.version_info < (3, 12): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(module: types.ModuleType) -> str: ... _NamespaceLoader = NamespaceLoader @@ -178,12 +180,16 @@ else: def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info >= (3, 10): @staticmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(module: types.ModuleType) -> str: ... def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... else: @classmethod - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(cls, module: types.ModuleType) -> str: ... if sys.version_info >= (3, 13): diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index f0342aa02be3..07587856d30f 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -8,7 +8,9 @@ if sys.version_info >= (3, 10): class Loader(metaclass=ABCMeta): def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + ) def module_repr(self, module: types.ModuleType) -> str: ... def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 620e9ca221c7..f8ec6cad0160 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -514,7 +514,9 @@ else: def formatannotationrelativeto(object: object) -> Callable[[object], str]: ... if sys.version_info < (3, 11): - @deprecated("Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and the `Signature` class instead.") + @deprecated( + "Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and the `Signature` class instead." + ) def formatargspec( args: list[str], varargs: str | None = None, From 549014a81e0a95ab63a79133d61bd6dccf2738d1 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 11 Aug 2025 01:02:44 +0400 Subject: [PATCH 7/8] Wrap comment lines --- stdlib/_frozen_importlib.pyi | 6 ++++-- stdlib/_frozen_importlib_external.pyi | 9 ++++++--- stdlib/importlib/_abc.pyi | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 1e34376e4613..93aaed82e2e1 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -70,7 +70,8 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) if sys.version_info < (3, 12): @staticmethod @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(module: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): @@ -108,7 +109,8 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): if sys.version_info < (3, 12): @staticmethod @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(m: types.ModuleType) -> str: ... if sys.version_info >= (3, 10): diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index 81d5ee814137..80eebe45a7d4 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -161,7 +161,8 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): @staticmethod @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(module: types.ModuleType) -> str: ... @@ -181,14 +182,16 @@ else: if sys.version_info >= (3, 10): @staticmethod @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(module: types.ModuleType) -> str: ... def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... else: @classmethod @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(cls, module: types.ModuleType) -> str: ... diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index 07587856d30f..90ab34021917 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -9,7 +9,8 @@ if sys.version_info >= (3, 10): def load_module(self, fullname: str) -> types.ModuleType: ... if sys.version_info < (3, 12): @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. The module spec is now used by the import machinery to generate a module repr." + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(self, module: types.ModuleType) -> str: ... From de8c8c1e1ce206653ae62198d4de9bdbb05defc4 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 11 Aug 2025 01:08:23 +0400 Subject: [PATCH 8/8] fix the rest --- stdlib/asyncio/trsock.pyi | 34 +++++++++++++++++----------------- stdlib/importlib/util.pyi | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 7d8ed6d48836..4dacbbd49399 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -73,51 +73,51 @@ class TransportSocket: self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... else: - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def sendmsg_afalg( self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> NoReturn: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def sendmsg( self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., / ) -> int: ... @overload - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def sendto(self, data: ReadableBuffer, address: _Address) -> int: ... @overload - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def send(self, data: ReadableBuffer, flags: int = ...) -> int: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def set_inheritable(self, inheritable: bool) -> None: ... if sys.platform == "win32": - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def share(self, process_id: int) -> bytes: ... else: - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def share(self, process_id: int) -> NoReturn: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recvmsg_into( self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., / ) -> tuple[int, list[_CMSG], int, Any]: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def __enter__(self) -> socket.socket: ... - @deprecated("Initially it was deprecated; removed in Python 3.11.") + @deprecated("Removed in Python 3.11.") def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 8f516037d1cc..05c4d0d1edb3 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -17,11 +17,20 @@ from typing_extensions import ParamSpec, deprecated _P = ParamSpec("_P") if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "`__name__`, `__package__` and `__loader__` are now set automatically." + ) def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "`__name__`, `__package__` and `__loader__` are now set automatically." + ) def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Now it's done automatically.") + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "`__name__`, `__package__` and `__loader__` are now set automatically." + ) def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... def resolve_name(name: str, package: str | None) -> str: ...