From 20e0dca964695bf1f1e961405d34697643bd9433 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 7 May 2026 19:36:55 +0200 Subject: [PATCH 1/3] Drop 3.9 support in the stdlib --- .../test_cases/check_importlib_metadata.py | 34 +- stdlib/@tests/test_cases/check_types.py | 19 +- .../itertools/check_itertools_recipes.py | 78 +- stdlib/_ast.pyi | 26 +- stdlib/_bisect.pyi | 228 +++--- stdlib/_codecs.pyi | 5 +- stdlib/_collections_abc.pyi | 17 +- stdlib/_csv.pyi | 63 +- stdlib/_ctypes.pyi | 15 +- stdlib/_curses.pyi | 17 +- stdlib/_frozen_importlib.pyi | 23 +- stdlib/_frozen_importlib_external.pyi | 62 +- stdlib/_hashlib.pyi | 3 +- stdlib/_io.pyi | 9 +- stdlib/_lsprof.pyi | 7 +- stdlib/_markupbase.pyi | 6 - stdlib/_random.pyi | 9 +- stdlib/_socket.pyi | 7 +- stdlib/_sqlite3.pyi | 12 +- stdlib/_ssl.pyi | 42 +- stdlib/_thread.pyi | 11 +- stdlib/_typeshed/__init__.pyi | 12 +- stdlib/_winapi.pyi | 35 +- stdlib/abc.pyi | 4 +- stdlib/array.pyi | 6 +- stdlib/ast.pyi | 512 ++++++------- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/locks.pyi | 31 +- stdlib/asyncio/proactor_events.pyi | 32 +- stdlib/asyncio/queues.pyi | 16 +- stdlib/asyncio/streams.pyi | 79 +- stdlib/asyncio/subprocess.pyi | 66 +- stdlib/asyncio/tasks.pyi | 395 +++------- stdlib/base64.pyi | 11 +- stdlib/builtins.pyi | 263 +++---- stdlib/calendar.pyi | 9 +- stdlib/collections/__init__.pyi | 45 +- stdlib/compileall.pyi | 101 +-- stdlib/contextlib.pyi | 87 +-- stdlib/csv.pyi | 6 +- stdlib/curses/__init__.pyi | 4 +- stdlib/dataclasses.pyi | 109 +-- stdlib/distutils/command/__init__.pyi | 7 - stdlib/distutils/command/install.pyi | 4 - stdlib/distutils/sysconfig.pyi | 4 - stdlib/email/_header_value_parser.pyi | 11 +- stdlib/email/errors.pyi | 6 +- stdlib/enum.pyi | 4 +- stdlib/fcntl.pyi | 7 +- stdlib/fileinput.pyi | 192 ++--- stdlib/glob.pyi | 27 +- stdlib/grp.pyi | 3 +- stdlib/http/cookiejar.pyi | 5 +- stdlib/importlib/_abc.pyi | 25 +- stdlib/importlib/abc.pyi | 83 +-- stdlib/importlib/metadata/__init__.pyi | 80 +- stdlib/importlib/readers.pyi | 87 ++- stdlib/importlib/resources/__init__.pyi | 6 +- stdlib/importlib/resources/_common.pyi | 2 +- stdlib/inspect.pyi | 18 +- stdlib/ipaddress.pyi | 2 +- stdlib/itertools.pyi | 11 +- stdlib/locale.pyi | 5 +- stdlib/logging/__init__.pyi | 39 +- stdlib/logging/config.pyi | 22 +- stdlib/mmap.pyi | 5 +- stdlib/msvcrt.pyi | 3 +- stdlib/multiprocessing/managers.pyi | 6 +- stdlib/os/__init__.pyi | 77 +- stdlib/pathlib/__init__.pyi | 42 +- stdlib/pdb.pyi | 5 - stdlib/platform.pyi | 8 +- stdlib/posix.pyi | 36 +- stdlib/pprint.pyi | 134 +--- stdlib/pwd.pyi | 3 +- stdlib/py_compile.pyi | 8 +- stdlib/pyclbr.pyi | 71 +- stdlib/pyexpat/__init__.pyi | 9 +- stdlib/random.pyi | 5 +- stdlib/resource.pyi | 37 +- stdlib/sched.pyi | 30 +- stdlib/signal.pyi | 24 +- stdlib/socket.pyi | 16 +- stdlib/spwd.pyi | 23 +- stdlib/sqlite3/__init__.pyi | 3 - stdlib/sqlite3/dbapi2.pyi | 18 +- stdlib/ssl.pyi | 111 +-- stdlib/statistics.pyi | 26 +- stdlib/subprocess.pyi | 704 ++---------------- stdlib/sys/__init__.pyi | 56 +- stdlib/sysconfig.pyi | 10 +- stdlib/tempfile.pyi | 14 +- stdlib/threading.pyi | 14 +- stdlib/time.pyi | 3 +- stdlib/tkinter/font.pyi | 8 +- stdlib/token.pyi | 7 +- stdlib/tokenize.pyi | 4 +- stdlib/traceback.pyi | 102 +-- stdlib/types.pyi | 135 ++-- stdlib/typing.pyi | 244 +++--- stdlib/typing_extensions.pyi | 68 +- stdlib/unicodedata.pyi | 6 +- stdlib/unittest/_log.pyi | 9 +- stdlib/unittest/case.pyi | 13 +- stdlib/unittest/mock.pyi | 82 +- stdlib/xml/sax/expatreader.pyi | 18 +- stdlib/xml/sax/handler.pyi | 14 +- stdlib/xxlimited.pyi | 13 +- stdlib/zipfile/__init__.pyi | 18 +- stdlib/zipimport.pyi | 43 +- 110 files changed, 1659 insertions(+), 3794 deletions(-) diff --git a/stdlib/@tests/test_cases/check_importlib_metadata.py b/stdlib/@tests/test_cases/check_importlib_metadata.py index 0c9bd44cf592..8f50496cbd69 100644 --- a/stdlib/@tests/test_cases/check_importlib_metadata.py +++ b/stdlib/@tests/test_cases/check_importlib_metadata.py @@ -1,28 +1,28 @@ from __future__ import annotations -import sys from _typeshed import StrPath +from importlib.metadata._meta import SimplePath from os import PathLike from pathlib import Path from zipfile import Path as ZipPath -if sys.version_info >= (3, 10): - from importlib.metadata._meta import SimplePath - # Simplified version of zipfile.Path - class MyPath: - @property - def parent(self) -> PathLike[str]: ... # undocumented +# Simplified version of zipfile.Path +class MyPath: + @property + def parent(self) -> PathLike[str]: ... # undocumented - def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ... - def read_bytes(self) -> bytes: ... - def joinpath(self, *other: StrPath) -> MyPath: ... - def __truediv__(self, add: StrPath) -> MyPath: ... - def exists(self) -> bool: ... + def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ... + def read_bytes(self) -> bytes: ... + def joinpath(self, *other: StrPath) -> MyPath: ... + def __truediv__(self, add: StrPath) -> MyPath: ... + def exists(self) -> bool: ... - def takes_simple_path(p: SimplePath) -> None: ... - takes_simple_path(Path()) - takes_simple_path(ZipPath("")) - takes_simple_path(MyPath()) - takes_simple_path("some string") # type: ignore +def takes_simple_path(p: SimplePath) -> None: ... + + +takes_simple_path(Path()) +takes_simple_path(ZipPath("")) +takes_simple_path(MyPath()) +takes_simple_path("some string") # type: ignore diff --git a/stdlib/@tests/test_cases/check_types.py b/stdlib/@tests/test_cases/check_types.py index 884557c74b88..d17a8b176fc8 100644 --- a/stdlib/@tests/test_cases/check_types.py +++ b/stdlib/@tests/test_cases/check_types.py @@ -65,16 +65,15 @@ def foo(self) -> None: # check that NotImplemented is treated as an "Any" x: int = NotImplemented -if sys.version_info >= (3, 10): - # test NotImplementedType usage - assert_type(NotImplemented, types.NotImplementedType) - assert_type(types.NotImplementedType(), types.NotImplementedType) - # test EllipsisType usage - assert_type(Ellipsis, types.EllipsisType) - assert_type(types.EllipsisType(), types.EllipsisType) - # test NoneType usage (disabled, passes with pyright, but mypy errors - # assert_type(None, types.NoneType) - # assert_type(types.NoneType(), types.NoneType) +# test NotImplementedType usage +assert_type(NotImplemented, types.NotImplementedType) +assert_type(types.NotImplementedType(), types.NotImplementedType) +# test EllipsisType usage +assert_type(Ellipsis, types.EllipsisType) +assert_type(types.EllipsisType(), types.EllipsisType) +# test NoneType usage (disabled, passes with pyright, but mypy errors +# assert_type(None, types.NoneType) +# assert_type(types.NoneType(), types.NoneType) if sys.version_info >= (3, 11): union_type = int | list[_T] diff --git a/stdlib/@tests/test_cases/itertools/check_itertools_recipes.py b/stdlib/@tests/test_cases/itertools/check_itertools_recipes.py index 6cba7b37026e..af5d256b44ea 100644 --- a/stdlib/@tests/test_cases/itertools/check_itertools_recipes.py +++ b/stdlib/@tests/test_cases/itertools/check_itertools_recipes.py @@ -326,44 +326,46 @@ def nth_combination(iterable: Iterable[_T], r: int, index: int) -> tuple[_T, ... return tuple(result) -if sys.version_info >= (3, 10): - - @overload - def grouper( - iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None - ) -> Iterator[tuple[_T | None, ...]]: ... - - @overload - def grouper( - iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1 - ) -> Iterator[tuple[_T | _T1, ...]]: ... - - @overload - def grouper( - iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None - ) -> Iterator[tuple[_T, ...]]: ... - - def grouper( - iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None - ) -> Iterator[tuple[object, ...]]: - "Collect data into non-overlapping fixed-length chunks or blocks" - # grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx - # grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError - # grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF - args = [iter(iterable)] * n - if incomplete == "fill": - return zip_longest(*args, fillvalue=fillvalue) - if incomplete == "strict": - return zip(*args, strict=True) - if incomplete == "ignore": - return zip(*args) - else: - raise ValueError("Expected fill, strict, or ignore") - - def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]: - "Swap the rows and columns of the input." - # transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33) - return zip(*it, strict=True) +@overload +def grouper( + iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None +) -> Iterator[tuple[_T | None, ...]]: ... + + +@overload +def grouper( + iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1 +) -> Iterator[tuple[_T | _T1, ...]]: ... + + +@overload +def grouper( + iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None +) -> Iterator[tuple[_T, ...]]: ... + + +def grouper( + iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None +) -> Iterator[tuple[object, ...]]: + "Collect data into non-overlapping fixed-length chunks or blocks" + # grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx + # grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError + # grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF + args = [iter(iterable)] * n + if incomplete == "fill": + return zip_longest(*args, fillvalue=fillvalue) + if incomplete == "strict": + return zip(*args, strict=True) + if incomplete == "ignore": + return zip(*args) + else: + raise ValueError("Expected fill, strict, or ignore") + + +def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]: + "Swap the rows and columns of the input." + # transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33) + return zip(*it, strict=True) if sys.version_info >= (3, 12): diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index d8d5a1829991..fd89973aefe6 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -58,6 +58,15 @@ from ast import ( LShift as LShift, Lt as Lt, LtE as LtE, + Match as Match, + MatchAs as MatchAs, + MatchClass as MatchClass, + MatchMapping as MatchMapping, + MatchOr as MatchOr, + MatchSequence as MatchSequence, + MatchSingleton as MatchSingleton, + MatchStar as MatchStar, + MatchValue as MatchValue, MatMult as MatMult, Mod as Mod, Module as Module, @@ -101,8 +110,10 @@ from ast import ( expr as expr, expr_context as expr_context, keyword as keyword, + match_case as match_case, mod as mod, operator as operator, + pattern as pattern, stmt as stmt, type_ignore as type_ignore, unaryop as unaryop, @@ -122,21 +133,6 @@ if sys.version_info >= (3, 12): if sys.version_info >= (3, 11): from ast import TryStar as TryStar -if sys.version_info >= (3, 10): - from ast import ( - Match as Match, - MatchAs as MatchAs, - MatchClass as MatchClass, - MatchMapping as MatchMapping, - MatchOr as MatchOr, - MatchSequence as MatchSequence, - MatchSingleton as MatchSingleton, - MatchStar as MatchStar, - MatchValue as MatchValue, - match_case as match_case, - pattern as pattern, - ) - PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192 PyCF_ONLY_AST: Final = 1024 PyCF_TYPE_COMMENTS: Final = 4096 diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 5ac43b3e0641..a0890c94457a 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,140 +1,100 @@ -import sys from _typeshed import SupportsGetItem, SupportsLenAndGetItem, SupportsRichComparisonT from collections.abc import Callable, MutableSequence from typing import TypeVar, overload _T = TypeVar("_T") -if sys.version_info >= (3, 10): - @overload - def bisect_left( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> int: ... - @overload - def bisect_left( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None - ) -> int: ... - @overload - def bisect_left( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None - ) -> int: ... - @overload - def bisect_left( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def bisect_left( - a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> int: ... - @overload - def bisect_left( - a: SupportsGetItem[int, _T], - x: SupportsRichComparisonT, - lo: int = 0, - *, - hi: int, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def bisect_right( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> int: ... - @overload - def bisect_right( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None - ) -> int: ... - @overload - def bisect_right( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None - ) -> int: ... - @overload - def bisect_right( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def bisect_right( - a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> int: ... - @overload - def bisect_right( - a: SupportsGetItem[int, _T], - x: SupportsRichComparisonT, - lo: int = 0, - *, - hi: int, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def insort_left( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> None: ... - @overload - def insort_left( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> None: ... - @overload - def insort_right( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> None: ... - @overload - def insort_right( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> None: ... - -else: - @overload - def bisect_left( - a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> int: ... - @overload - def bisect_left(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ... - @overload - def bisect_left( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int - ) -> int: ... - @overload - def bisect_right( - a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> int: ... - @overload - def bisect_right(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ... - @overload - def bisect_right( - a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int - ) -> int: ... - def insort_left( - a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> None: ... - def insort_right( - a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> None: ... +@overload +def bisect_left( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> int: ... +@overload +def bisect_left( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None +) -> int: ... +@overload +def bisect_left( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None +) -> int: ... +@overload +def bisect_left( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], +) -> int: ... +@overload +def bisect_left( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] +) -> int: ... +@overload +def bisect_left( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: Callable[[_T], SupportsRichComparisonT] +) -> int: ... +@overload +def bisect_right( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> int: ... +@overload +def bisect_right( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None +) -> int: ... +@overload +def bisect_right( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None +) -> int: ... +@overload +def bisect_right( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], +) -> int: ... +@overload +def bisect_right( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] +) -> int: ... +@overload +def bisect_right( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: Callable[[_T], SupportsRichComparisonT] +) -> int: ... +@overload +def insort_left( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> None: ... +@overload +def insort_left( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] +) -> None: ... +@overload +def insort_right( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> None: ... +@overload +def insort_right( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] +) -> None: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 89cb78c33571..7d862672c367 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -17,10 +17,7 @@ _Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]] _SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None] def register(search_function: _SearchFunction, /) -> None: ... - -if sys.version_info >= (3, 10): - def unregister(search_function: _SearchFunction, /) -> None: ... - +def unregister(search_function: _SearchFunction, /) -> None: ... def register_error(errors: str, handler: _Handler, /) -> None: ... def lookup_error(name: str, /) -> _Handler: ... diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index 0fa81662dfbc..d2499627d273 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -75,16 +75,15 @@ class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented def __reversed__(self) -> Iterator[_VT_co]: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented @@ -93,9 +92,9 @@ class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... if sys.version_info >= (3, 12): @runtime_checkable diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index ea90766afee6..c3bc5bf63ade 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -2,7 +2,7 @@ import csv import sys from _typeshed import SupportsWrite from collections.abc import Iterable -from typing import Any, Final, Literal, type_check_only +from typing import Any, Final, Literal from typing_extensions import Self, TypeAlias, disjoint_base __version__: Final[str] @@ -47,47 +47,24 @@ class Dialect: strict: bool = False, ) -> Self: ... -if sys.version_info >= (3, 10): - # This class calls itself _csv.reader. - @disjoint_base - class Reader: - @property - def dialect(self) -> Dialect: ... - line_num: int - def __iter__(self) -> Self: ... - def __next__(self) -> list[str]: ... - - # This class calls itself _csv.writer. - @disjoint_base - class Writer: - @property - def dialect(self) -> Dialect: ... - if sys.version_info >= (3, 13): - def writerow(self, row: Iterable[Any], /) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... - else: - def writerow(self, row: Iterable[Any]) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... - - # For the return types below. - # These aliases can be removed when typeshed drops support for 3.9. - _reader = Reader - _writer = Writer -else: - # This class is not exposed. It calls itself _csv.reader. - @type_check_only - class _reader: - @property - def dialect(self) -> Dialect: ... - line_num: int - def __iter__(self) -> Self: ... - def __next__(self) -> list[str]: ... +# This class calls itself _csv.reader. +@disjoint_base +class Reader: + @property + def dialect(self) -> Dialect: ... + line_num: int + def __iter__(self) -> Self: ... + def __next__(self) -> list[str]: ... - # This class is not exposed. It calls itself _csv.writer. - @type_check_only - class _writer: - @property - def dialect(self) -> Dialect: ... +# This class calls itself _csv.writer. +@disjoint_base +class Writer: + @property + def dialect(self) -> Dialect: ... + if sys.version_info >= (3, 13): + def writerow(self, row: Iterable[Any], /) -> Any: ... + def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... + else: def writerow(self, row: Iterable[Any]) -> Any: ... def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... @@ -104,7 +81,7 @@ def writer( lineterminator: str = "\r\n", quoting: _QuotingType = 0, strict: bool = False, -) -> _writer: ... +) -> Writer: ... def reader( iterable: Iterable[str], /, @@ -118,7 +95,7 @@ def reader( lineterminator: str = "\r\n", quoting: _QuotingType = 0, strict: bool = False, -) -> _reader: ... +) -> Reader: ... def register_dialect( name: str, /, diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 3c4308628c8c..af0e634b24a8 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -223,17 +223,10 @@ else: class _CField(Generic[_CT, _GetT, _SetT]): offset: int size: int - if sys.version_info >= (3, 10): - @overload - def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... - else: - @overload - def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ... - + @overload + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... def __set__(self, instance: Any, value: _SetT, /) -> None: ... # This class is not exposed. It calls itself _ctypes.UnionType. diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index d4e4d48f4e20..bf8dc7a8274e 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -96,13 +96,12 @@ BUTTON4_PRESSED: Final[int] BUTTON4_RELEASED: Final[int] BUTTON4_TRIPLE_CLICKED: Final[int] # Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3 -if sys.version_info >= (3, 10): - if sys.version_info >= (3, 12) or sys.platform != "darwin": - BUTTON5_PRESSED: Final[int] - BUTTON5_RELEASED: Final[int] - BUTTON5_CLICKED: Final[int] - BUTTON5_DOUBLE_CLICKED: Final[int] - BUTTON5_TRIPLE_CLICKED: Final[int] +if sys.version_info >= (3, 12) or sys.platform != "darwin": + BUTTON5_PRESSED: Final[int] + BUTTON5_RELEASED: Final[int] + BUTTON5_CLICKED: Final[int] + BUTTON5_DOUBLE_CLICKED: Final[int] + BUTTON5_TRIPLE_CLICKED: Final[int] BUTTON_ALT: Final[int] BUTTON_CTRL: Final[int] BUTTON_SHIFT: Final[int] @@ -300,9 +299,7 @@ def getsyx() -> tuple[int, int]: ... def getwin(file: SupportsRead[bytes], /) -> window: ... def halfdelay(tenths: int, /) -> None: ... def has_colors() -> bool: ... - -if sys.version_info >= (3, 10): - def has_extended_color_support() -> bool: ... +def has_extended_color_support() -> bool: ... if sys.version_info >= (3, 14): def assume_default_colors(fg: int, bg: int, /) -> None: ... diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 58db64a016f3..172da4522d8f 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -74,16 +74,11 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) "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 - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... - @staticmethod - def exec_module(module: types.ModuleType) -> None: ... - else: - @classmethod - def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... - @classmethod - def exec_module(cls, module: types.ModuleType) -> None: ... + + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... + @staticmethod + def exec_module(module: types.ModuleType) -> None: ... class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @@ -113,12 +108,8 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): "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 - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... - else: - @classmethod - def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... @staticmethod def exec_module(module: types.ModuleType) -> None: ... diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index 660cee6e84ec..f5b1045a11f0 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -1,19 +1,16 @@ import _ast -import _io import importlib.abc import importlib.machinery +import importlib.readers import sys import types from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath from _typeshed.importlib import LoaderProtocol -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableSequence, Sequence +from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence from importlib.machinery import ModuleSpec from importlib.metadata import DistributionFinder, PathDistribution from typing import Any, Final, Literal, overload -from typing_extensions import Self, deprecated - -if sys.version_info >= (3, 10): - import importlib.readers +from typing_extensions import deprecated if sys.platform == "win32": path_separators: Literal["\\/"] @@ -58,19 +55,10 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder): ) -> ModuleSpec | None: ... class PathFinder(importlib.abc.MetaPathFinder): - if sys.version_info >= (3, 10): - @staticmethod - def invalidate_caches() -> None: ... - else: - @classmethod - def invalidate_caches(cls) -> None: ... - if sys.version_info >= (3, 10): - @staticmethod - def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... - else: - @classmethod - def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... - + @staticmethod + def invalidate_caches() -> None: ... + @staticmethod + def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... @classmethod def find_spec( cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None @@ -117,14 +105,7 @@ class FileLoader: def get_data(self, path: str) -> bytes: ... def get_filename(self, fullname: str | None = None) -> str: ... def load_module(self, fullname: str | None = None) -> types.ModuleType: ... - if sys.version_info >= (3, 10): - def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... - else: - def get_resource_reader(self, name: str | None = None) -> Self | None: ... - def open_resource(self, resource: str) -> _io.FileIO: ... - def resource_path(self, resource: str) -> str: ... - def is_resource(self, name: str) -> bool: ... - def contents(self) -> Iterator[str]: ... + def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... class SourceFileLoader(importlib.abc.FileLoader, FileLoader, importlib.abc.SourceLoader, SourceLoader): # type: ignore[misc] # incompatible method arguments in base classes def set_data(self, path: str, data: ReadableBuffer, *, _mode: int = 0o666) -> None: ... @@ -183,24 +164,15 @@ else: def get_code(self, fullname: str) -> types.CodeType: ... def create_module(self, spec: ModuleSpec) -> None: ... def exec_module(self, module: types.ModuleType) -> None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") - def load_module(self, fullname: str) -> types.ModuleType: ... - @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." - ) - def module_repr(module: types.ModuleType) -> str: ... - def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... - else: - def load_module(self, fullname: str) -> types.ModuleType: ... - @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." - ) - def module_repr(cls, module: types.ModuleType) -> str: ... + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> types.ModuleType: ... + @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." + ) + def module_repr(module: types.ModuleType) -> str: ... + def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... if sys.version_info >= (3, 13): class AppleFrameworkLoader(ExtensionFileLoader, importlib.abc.ExecutionLoader): ... diff --git a/stdlib/_hashlib.pyi b/stdlib/_hashlib.pyi index 03c1eef3be3f..2b7f1d4eb457 100644 --- a/stdlib/_hashlib.pyi +++ b/stdlib/_hashlib.pyi @@ -35,8 +35,7 @@ class HASH: def hexdigest(self) -> str: ... def update(self, obj: ReadableBuffer, /) -> None: ... -if sys.version_info >= (3, 10): - class UnsupportedDigestmodError(ValueError): ... +class UnsupportedDigestmodError(ValueError): ... class HASHXOF(HASH): def digest(self, length: int) -> bytes: ... # type: ignore[override] diff --git a/stdlib/_io.pyi b/stdlib/_io.pyi index 8caa4ad1a203..5e216123be98 100644 --- a/stdlib/_io.pyi +++ b/stdlib/_io.pyi @@ -324,8 +324,7 @@ class IncrementalNewlineDecoder: def reset(self) -> None: ... def setstate(self, state: tuple[bytes, int], /) -> None: ... -if sys.version_info >= (3, 10): - @overload - def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... - @overload - def text_encoding(encoding: _S, stacklevel: int = 2, /) -> _S: ... +@overload +def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... +@overload +def text_encoding(encoding: _S, stacklevel: int = 2, /) -> _S: ... diff --git a/stdlib/_lsprof.pyi b/stdlib/_lsprof.pyi index 4f6d98b8ffb6..d04c2a74ee07 100644 --- a/stdlib/_lsprof.pyi +++ b/stdlib/_lsprof.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import structseq from collections.abc import Callable from types import CodeType @@ -17,8 +16,7 @@ class Profiler: @final class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") code: CodeType | str callcount: int reccallcount: int @@ -28,8 +26,7 @@ class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, floa @final class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") code: CodeType | str callcount: int reccallcount: int diff --git a/stdlib/_markupbase.pyi b/stdlib/_markupbase.pyi index 597bd09b700b..acc3ccac7188 100644 --- a/stdlib/_markupbase.pyi +++ b/stdlib/_markupbase.pyi @@ -1,6 +1,3 @@ -import sys -from typing import Any - class ParserBase: def reset(self) -> None: ... def getpos(self) -> tuple[int, int]: ... @@ -9,8 +6,5 @@ class ParserBase: def parse_declaration(self, i: int) -> int: ... # undocumented def parse_marked_section(self, i: int, report: bool = True) -> int: ... # undocumented def updatepos(self, i: int, j: int) -> int: ... # undocumented - if sys.version_info < (3, 10): - # Removed from ParserBase: https://bugs.python.org/issue31844 - def error(self, message: str) -> Any: ... # undocumented lineno: int # undocumented offset: int # undocumented diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index ac00fdfb7272..04731b7f4c55 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,16 +1,11 @@ -import sys -from typing_extensions import Self, TypeAlias, disjoint_base +from typing_extensions import TypeAlias, disjoint_base # Actually Tuple[(int,) * 625] _State: TypeAlias = tuple[int, ...] @disjoint_base class Random: - if sys.version_info >= (3, 10): - def __init__(self, seed: object = ..., /) -> None: ... - else: - def __new__(self, seed: object = ..., /) -> Self: ... - + def __init__(self, seed: object = ..., /) -> None: ... def seed(self, n: object = None, /) -> None: ... def getstate(self) -> _State: ... def setstate(self, state: _State, /) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 918bffc7f908..44d98ccab9ce 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -195,7 +195,7 @@ if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "lin if sys.platform == "linux": # Availability: Linux >= 2.6.20, FreeBSD >= 10.1 IPPROTO_UDPLITE: Final[int] -if sys.version_info >= (3, 10) and sys.platform == "linux": +if sys.platform == "linux": IPPROTO_MPTCP: Final[int] IPPORT_RESERVED: Final[int] @@ -218,8 +218,7 @@ IP_MULTICAST_TTL: Final[int] IP_OPTIONS: Final[int] if sys.platform != "linux": IP_RECVDSTADDR: Final[int] -if sys.version_info >= (3, 10): - IP_RECVTOS: Final[int] +IP_RECVTOS: Final[int] IP_TOS: Final[int] IP_TTL: Final[int] if sys.platform != "win32": @@ -343,7 +342,7 @@ if sys.platform != "win32": TCP_NOTSENT_LOWAT: Final[int] if sys.platform != "darwin": TCP_KEEPIDLE: Final[int] -if sys.version_info >= (3, 10) and sys.platform == "darwin": +if sys.platform == "darwin": TCP_KEEPALIVE: Final[int] if sys.version_info >= (3, 11) and sys.platform == "darwin": TCP_CONNECTION_INFO: Final[int] diff --git a/stdlib/_sqlite3.pyi b/stdlib/_sqlite3.pyi index 5361584d6b18..b5168695dbba 100644 --- a/stdlib/_sqlite3.pyi +++ b/stdlib/_sqlite3.pyi @@ -305,13 +305,5 @@ if sys.version_info < (3, 12): ) def enable_shared_cache(do_enable: int) -> None: ... # undocumented -if sys.version_info >= (3, 10): - def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... - def register_converter(typename: str, converter: _Converter, /) -> None: ... - -else: - def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ... - def register_converter(name: str, converter: _Converter, /) -> None: ... - -if sys.version_info < (3, 10): - OptimizedUnicode = str # undocumented +def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... +def register_converter(typename: str, converter: _Converter, /) -> None: ... diff --git a/stdlib/_ssl.pyi b/stdlib/_ssl.pyi index e84b24e8f4db..1310d58f3bba 100644 --- a/stdlib/_ssl.pyi +++ b/stdlib/_ssl.pyi @@ -54,10 +54,6 @@ 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): - @deprecated("Unsupported by OpenSSL since 1.1.1; removed in Python 3.10.") - def RAND_egd(path: str) -> None: ... - def RAND_status() -> bool: ... def get_default_verify_paths() -> tuple[str, str, str, str]: ... @@ -78,8 +74,7 @@ class _SSLContext: options: int post_handshake_auth: bool protocol: int - if sys.version_info >= (3, 10): - security_level: int + security_level: int sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None verify_flags: int verify_mode: int @@ -145,18 +140,17 @@ class SSLSession: # # You can find a _ssl._SSLSocket object as the _sslobj attribute of a ssl.SSLSocket object -if sys.version_info >= (3, 10): - @final - class Certificate: - def get_info(self) -> _CertInfo: ... - @overload - def public_bytes(self) -> str: ... - @overload - def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM - @overload - def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER - @overload - def public_bytes(self, format: int, /) -> str | bytes: ... +@final +class Certificate: + def get_info(self) -> _CertInfo: ... + @overload + def public_bytes(self) -> str: ... + @overload + def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM + @overload + def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER + @overload + def public_bytes(self, format: int, /) -> str | bytes: ... if sys.version_info < (3, 12): err_codes_to_names: dict[tuple[int, int], str] @@ -187,9 +181,8 @@ VERIFY_CRL_CHECK_LEAF: Final = 0x04 VERIFY_CRL_CHECK_CHAIN: Final = 0x0C VERIFY_X509_STRICT: Final = 0x20 VERIFY_X509_TRUSTED_FIRST: Final = 0x8000 -if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 - VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 +VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 +VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 # alert descriptions ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = 0 @@ -258,10 +251,9 @@ HOSTFLAG_NO_PARTIAL_WILDCARDS: Final = 0x4 HOSTFLAG_MULTI_LABEL_WILDCARDS: Final = 0x8 HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: Final = 0x10 -if sys.version_info >= (3, 10): - # certificate file types - ENCODING_PEM: Final = 1 - ENCODING_DER: Final = 2 +# certificate file types +ENCODING_PEM: Final = 1 +ENCODING_DER: Final = 2 # protocol versions PROTO_MINIMUM_SUPPORTED: Final = -2 diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 1323a55e9aad..69fac7a5a694 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -77,13 +77,7 @@ def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts] @overload @deprecated("Obsolete synonym. Use `start_new_thread()` instead.") def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented - -if sys.version_info >= (3, 10): - def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... - -else: - def interrupt_main() -> None: ... - +def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... def exit() -> NoReturn: ... @deprecated("Obsolete synonym. Use `exit()` instead.") def exit_thread() -> NoReturn: ... # undocumented @@ -98,8 +92,7 @@ TIMEOUT_MAX: Final[float] def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") + __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") @property def exc_type(self) -> type[BaseException]: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c006322b8145..796c62370f34 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -6,7 +6,7 @@ import sys from collections.abc import Awaitable, Callable, Iterable, Iterator, Sequence, Set as AbstractSet, Sized from dataclasses import Field from os import PathLike -from types import FrameType, TracebackType +from types import FrameType, NoneType as NoneType, TracebackType from typing import ( Any, AnyStr, @@ -19,7 +19,6 @@ from typing import ( SupportsIndex, SupportsInt, TypeVar, - final, overload, ) from typing_extensions import Buffer, LiteralString, Self as _Self, TypeAlias @@ -323,15 +322,6 @@ class SizedBuffer(Sized, Buffer, Protocol): ... ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None] -# stable -if sys.version_info >= (3, 10): - from types import NoneType as NoneType -else: - # Used by type checkers for checks involving None (does not exist at runtime) - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... - # This is an internal CPython type that is like, but subtly different from, a NamedTuple # Subclasses of this type are found in multiple modules. # In typeshed, `structseq` is only ever used as a mixin in combination with a fixed-length `Tuple` diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 42efce9bed70..253f6af447f6 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -127,22 +127,21 @@ if sys.platform == "win32": WAIT_OBJECT_0: Final = 0 WAIT_TIMEOUT: Final = 258 - if sys.version_info >= (3, 10): - LOCALE_NAME_INVARIANT: Final[str] - LOCALE_NAME_MAX_LENGTH: Final[int] - LOCALE_NAME_SYSTEM_DEFAULT: Final[str] - LOCALE_NAME_USER_DEFAULT: Final[str | None] + LOCALE_NAME_INVARIANT: Final[str] + LOCALE_NAME_MAX_LENGTH: Final[int] + LOCALE_NAME_SYSTEM_DEFAULT: Final[str] + LOCALE_NAME_USER_DEFAULT: Final[str | None] - LCMAP_FULLWIDTH: Final[int] - LCMAP_HALFWIDTH: Final[int] - LCMAP_HIRAGANA: Final[int] - LCMAP_KATAKANA: Final[int] - LCMAP_LINGUISTIC_CASING: Final[int] - LCMAP_LOWERCASE: Final[int] - LCMAP_SIMPLIFIED_CHINESE: Final[int] - LCMAP_TITLECASE: Final[int] - LCMAP_TRADITIONAL_CHINESE: Final[int] - LCMAP_UPPERCASE: Final[int] + LCMAP_FULLWIDTH: Final[int] + LCMAP_HALFWIDTH: Final[int] + LCMAP_HIRAGANA: Final[int] + LCMAP_KATAKANA: Final[int] + LCMAP_LINGUISTIC_CASING: Final[int] + LCMAP_LOWERCASE: Final[int] + LCMAP_SIMPLIFIED_CHINESE: Final[int] + LCMAP_TITLECASE: Final[int] + LCMAP_TRADITIONAL_CHINESE: Final[int] + LCMAP_UPPERCASE: Final[int] if sys.version_info >= (3, 12): COPYFILE2_CALLBACK_CHUNK_STARTED: Final = 1 @@ -243,10 +242,8 @@ if sys.platform == "win32": ) -> int: ... def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ... def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ... - if sys.version_info >= (3, 10): - def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... - def UnmapViewOfFile(address: int, /) -> None: ... - + def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... + def UnmapViewOfFile(address: int, /) -> None: ... @overload def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 7e76abace214..66dafeff6364 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -46,6 +46,4 @@ class ABC(metaclass=ABCMeta): __slots__ = () def get_cache_token() -> object: ... - -if sys.version_info >= (3, 10): - def update_abstractmethods(cls: type[_T]) -> type[_T]: ... +def update_abstractmethods(cls: type[_T]) -> type[_T]: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index eb679dd50f72..ff8885042ba6 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -61,11 +61,7 @@ class array(MutableSequence[_T]): def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None: ... def fromlist(self, list: list[_T], /) -> None: ... def fromunicode(self, ustr: str, /) -> None: ... - if sys.version_info >= (3, 10): - def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... - else: - def index(self, v: _T, /) -> int: ... # type: ignore[override] - + def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... def insert(self, i: int, v: _T, /) -> None: ... def pop(self, i: int = -1, /) -> _T: ... def remove(self, v: _T, /) -> None: ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index e66e609ee664..a3e11576fc55 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -10,6 +10,7 @@ from _ast import ( ) from _typeshed import ReadableBuffer, Unused from collections.abc import Iterable, Iterator, Sequence +from types import EllipsisType from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload, type_check_only from typing_extensions import Self, Unpack, deprecated, disjoint_base @@ -44,16 +45,14 @@ if sys.version_info >= (3, 12): else: class AST: - if sys.version_info >= (3, 10): - __match_args__ = () + __match_args__ = () _attributes: ClassVar[tuple[str, ...]] _fields: ClassVar[tuple[str, ...]] class mod(AST): ... class Module(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "type_ignores") + __match_args__ = ("body", "type_ignores") body: list[stmt] type_ignores: list[TypeIgnore] if sys.version_info >= (3, 13): @@ -65,8 +64,7 @@ class Module(mod): def __replace__(self, *, body: list[stmt] = ..., type_ignores: list[TypeIgnore] = ...) -> Self: ... class Interactive(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) + __match_args__ = ("body",) body: list[stmt] if sys.version_info >= (3, 13): def __init__(self, body: list[stmt] = ...) -> None: ... @@ -77,8 +75,7 @@ class Interactive(mod): def __replace__(self, *, body: list[stmt] = ...) -> Self: ... class Expression(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) + __match_args__ = ("body",) body: expr def __init__(self, body: expr) -> None: ... @@ -86,8 +83,7 @@ class Expression(mod): def __replace__(self, *, body: expr = ...) -> Self: ... class FunctionType(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("argtypes", "returns") + __match_args__ = ("argtypes", "returns") argtypes: list[expr] returns: expr if sys.version_info >= (3, 13): @@ -114,7 +110,7 @@ class stmt(AST): class FunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -191,7 +187,7 @@ class FunctionDef(stmt): class AsyncFunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -268,7 +264,7 @@ class AsyncFunctionDef(stmt): class ClassDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "bases", "keywords", "body", "decorator_list") name: str bases: list[expr] @@ -324,8 +320,7 @@ class ClassDef(stmt): ) -> Self: ... class Return(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -333,8 +328,7 @@ class Return(stmt): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Delete(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets",) + __match_args__ = ("targets",) targets: list[expr] if sys.version_info >= (3, 13): def __init__(self, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -345,8 +339,7 @@ class Delete(stmt): def __replace__(self, *, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Assign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets", "value", "type_comment") + __match_args__ = ("targets", "value", "type_comment") targets: list[expr] value: expr type_comment: str | None @@ -400,8 +393,7 @@ if sys.version_info >= (3, 12): ) -> Self: ... class AugAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "op", "value") + __match_args__ = ("target", "op", "value") target: Name | Attribute | Subscript op: operator value: expr @@ -420,8 +412,7 @@ class AugAssign(stmt): ) -> Self: ... class AnnAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "annotation", "value", "simple") + __match_args__ = ("target", "annotation", "value", "simple") target: Name | Attribute | Subscript annotation: expr value: expr | None @@ -458,8 +449,7 @@ class AnnAssign(stmt): ) -> Self: ... class For(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -499,8 +489,7 @@ class For(stmt): ) -> Self: ... class AsyncFor(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -540,8 +529,7 @@ class AsyncFor(stmt): ) -> Self: ... class While(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -558,8 +546,7 @@ class While(stmt): ) -> Self: ... class If(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -576,8 +563,7 @@ class If(stmt): ) -> Self: ... class With(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -605,8 +591,7 @@ class With(stmt): ) -> Self: ... class AsyncWith(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -634,8 +619,7 @@ class AsyncWith(stmt): ) -> Self: ... class Raise(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("exc", "cause") + __match_args__ = ("exc", "cause") exc: expr | None cause: expr | None def __init__(self, exc: expr | None = None, cause: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -644,8 +628,7 @@ class Raise(stmt): def __replace__(self, *, exc: expr | None = ..., cause: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Try(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "handlers", "orelse", "finalbody") + __match_args__ = ("body", "handlers", "orelse", "finalbody") body: list[stmt] handlers: list[ExceptHandler] orelse: list[stmt] @@ -718,8 +701,7 @@ if sys.version_info >= (3, 11): ) -> Self: ... class Assert(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "msg") + __match_args__ = ("test", "msg") test: expr msg: expr | None def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -728,8 +710,7 @@ class Assert(stmt): def __replace__(self, *, test: expr = ..., msg: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Import(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[alias] if sys.version_info >= (3, 13): def __init__(self, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -740,8 +721,7 @@ class Import(stmt): def __replace__(self, *, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ImportFrom(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("module", "names", "level") + __match_args__ = ("module", "names", "level") module: str | None names: list[alias] level: int @@ -766,8 +746,7 @@ class ImportFrom(stmt): ) -> Self: ... class Global(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -778,8 +757,7 @@ class Global(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Nonlocal(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -790,8 +768,7 @@ class Nonlocal(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Expr(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -813,8 +790,7 @@ class expr(AST): def __replace__(self, **kwargs: Unpack[_Attributes]) -> Self: ... class BoolOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "values") + __match_args__ = ("op", "values") op: boolop values: list[expr] if sys.version_info >= (3, 13): @@ -826,8 +802,7 @@ class BoolOp(expr): def __replace__(self, *, op: boolop = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class NamedExpr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "value") + __match_args__ = ("target", "value") target: Name value: expr def __init__(self, target: Name, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -836,8 +811,7 @@ class NamedExpr(expr): def __replace__(self, *, target: Name = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class BinOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "op", "right") + __match_args__ = ("left", "op", "right") left: expr op: operator right: expr @@ -849,8 +823,7 @@ class BinOp(expr): ) -> Self: ... class UnaryOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "operand") + __match_args__ = ("op", "operand") op: unaryop operand: expr def __init__(self, op: unaryop, operand: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -859,8 +832,7 @@ class UnaryOp(expr): def __replace__(self, *, op: unaryop = ..., operand: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Lambda(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("args", "body") + __match_args__ = ("args", "body") args: arguments body: expr def __init__(self, args: arguments, body: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -869,8 +841,7 @@ class Lambda(expr): def __replace__(self, *, args: arguments = ..., body: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class IfExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: expr orelse: expr @@ -882,8 +853,7 @@ class IfExp(expr): ) -> Self: ... class Dict(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("keys", "values") + __match_args__ = ("keys", "values") keys: list[expr | None] values: list[expr] if sys.version_info >= (3, 13): @@ -897,8 +867,7 @@ class Dict(expr): ) -> Self: ... class Set(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts",) + __match_args__ = ("elts",) elts: list[expr] if sys.version_info >= (3, 13): def __init__(self, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -909,8 +878,7 @@ class Set(expr): def __replace__(self, *, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ListComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -924,8 +892,7 @@ class ListComp(expr): ) -> Self: ... class SetComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -939,8 +906,7 @@ class SetComp(expr): ) -> Self: ... class DictComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("key", "value", "generators") + __match_args__ = ("key", "value", "generators") key: expr value: expr generators: list[comprehension] @@ -957,8 +923,7 @@ class DictComp(expr): ) -> Self: ... class GeneratorExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -972,8 +937,7 @@ class GeneratorExp(expr): ) -> Self: ... class Await(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -981,8 +945,7 @@ class Await(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Yield(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -990,8 +953,7 @@ class Yield(expr): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class YieldFrom(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -999,8 +961,7 @@ class YieldFrom(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Compare(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "ops", "comparators") + __match_args__ = ("left", "ops", "comparators") left: expr ops: list[cmpop] comparators: list[expr] @@ -1017,8 +978,7 @@ class Compare(expr): ) -> Self: ... class Call(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("func", "args", "keywords") + __match_args__ = ("func", "args", "keywords") func: expr args: list[expr] keywords: list[keyword] @@ -1035,8 +995,7 @@ class Call(expr): ) -> Self: ... class FormattedValue(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "conversion", "format_spec") + __match_args__ = ("value", "conversion", "format_spec") value: expr conversion: int format_spec: expr | None @@ -1048,8 +1007,7 @@ class FormattedValue(expr): ) -> Self: ... class JoinedStr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("values",) + __match_args__ = ("values",) values: list[expr] if sys.version_info >= (3, 13): def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1090,17 +1048,10 @@ if sys.version_info >= (3, 14): **kwargs: Unpack[_Attributes], ) -> Self: ... -if sys.version_info >= (3, 10): - from types import EllipsisType - - _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType -else: - # Rely on builtins.ellipsis - _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821 +_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType class Constant(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "kind") + __match_args__ = ("value", "kind") value: _ConstantValue kind: str | None if sys.version_info < (3, 14): @@ -1124,8 +1075,7 @@ class Constant(expr): def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Attribute(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "attr", "ctx") + __match_args__ = ("value", "attr", "ctx") value: expr attr: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1137,8 +1087,7 @@ class Attribute(expr): ) -> Self: ... class Subscript(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "slice", "ctx") + __match_args__ = ("value", "slice", "ctx") value: expr slice: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1150,8 +1099,7 @@ class Subscript(expr): ) -> Self: ... class Starred(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "ctx") + __match_args__ = ("value", "ctx") value: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, value: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1160,8 +1108,7 @@ class Starred(expr): def __replace__(self, *, value: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Name(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("id", "ctx") + __match_args__ = ("id", "ctx") id: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, id: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1170,8 +1117,7 @@ class Name(expr): def __replace__(self, *, id: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class List(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` if sys.version_info >= (3, 13): @@ -1183,8 +1129,7 @@ class List(expr): def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Tuple(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` dims: list[expr] @@ -1200,8 +1145,7 @@ class Tuple(expr): class slice(AST): ... class Slice(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("lower", "upper", "step") + __match_args__ = ("lower", "upper", "step") lower: expr | None upper: expr | None step: expr | None @@ -1274,8 +1218,7 @@ class In(cmpop): ... class NotIn(cmpop): ... class comprehension(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "ifs", "is_async") + __match_args__ = ("target", "iter", "ifs", "is_async") target: expr iter: expr ifs: list[expr] @@ -1304,8 +1247,7 @@ class excepthandler(AST): ) -> Self: ... class ExceptHandler(excepthandler): - if sys.version_info >= (3, 10): - __match_args__ = ("type", "name", "body") + __match_args__ = ("type", "name", "body") type: expr | None name: str | None body: list[stmt] @@ -1327,8 +1269,7 @@ class ExceptHandler(excepthandler): ) -> Self: ... class arguments(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") + __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") posonlyargs: list[arg] args: list[arg] vararg: arg | None @@ -1398,12 +1339,11 @@ class arguments(AST): ) -> Self: ... class arg(AST): + __match_args__ = ("arg", "annotation", "type_comment") lineno: int col_offset: int end_lineno: int | None end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "annotation", "type_comment") arg: str annotation: expr | None type_comment: str | None @@ -1417,12 +1357,11 @@ class arg(AST): ) -> Self: ... class keyword(AST): + __match_args__ = ("arg", "value") lineno: int col_offset: int end_lineno: int | None end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "value") arg: str | None value: expr @overload @@ -1434,26 +1373,20 @@ class keyword(AST): def __replace__(self, *, arg: str | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class alias(AST): + __match_args__ = ("name", "asname") name: str asname: str | None - if sys.version_info >= (3, 10): - lineno: int - col_offset: int - end_lineno: int | None - end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("name", "asname") - if sys.version_info >= (3, 10): - def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... - else: - def __init__(self, name: str, asname: str | None = None) -> None: ... + lineno: int + col_offset: int + end_lineno: int | None + end_col_offset: int | None + def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... if sys.version_info >= (3, 14): def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class withitem(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("context_expr", "optional_vars") + __match_args__ = ("context_expr", "optional_vars") context_expr: expr optional_vars: expr | None def __init__(self, context_expr: expr, optional_vars: expr | None = None) -> None: ... @@ -1461,177 +1394,173 @@ class withitem(AST): if sys.version_info >= (3, 14): def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ... -if sys.version_info >= (3, 10): - class pattern(AST): - lineno: int - col_offset: int - end_lineno: int - end_col_offset: int - def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class pattern(AST): + lineno: int + col_offset: int + end_lineno: int + end_col_offset: int + def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... + ) -> Self: ... - class match_case(AST): - __match_args__ = ("pattern", "guard", "body") - pattern: ast.pattern - guard: expr | None - body: list[stmt] - if sys.version_info >= (3, 13): - def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... - elif sys.version_info >= (3, 10): - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... +class match_case(AST): + __match_args__ = ("pattern", "guard", "body") + pattern: ast.pattern + guard: expr | None + body: list[stmt] + if sys.version_info >= (3, 13): + def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... + else: + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... - class Match(stmt): - __match_args__ = ("subject", "cases") - subject: expr - cases: list[match_case] - if sys.version_info >= (3, 13): - def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... - else: - def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... +class Match(stmt): + __match_args__ = ("subject", "cases") + subject: expr + cases: list[match_case] + if sys.version_info >= (3, 13): + def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... + else: + def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes] - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... - class MatchValue(pattern): - __match_args__ = ("value",) - value: expr - def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchValue(pattern): + __match_args__ = ("value",) + value: expr + def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchSingleton(pattern): - __match_args__ = ("value",) - value: bool | None - def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchSingleton(pattern): + __match_args__ = ("value",) + value: bool | None + def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchSequence(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchSequence(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchMapping(pattern): - __match_args__ = ("keys", "patterns", "rest") - keys: list[expr] - patterns: list[pattern] - rest: str | None - if sys.version_info >= (3, 13): - def __init__( - self, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = None, - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... +class MatchMapping(pattern): + __match_args__ = ("keys", "patterns", "rest") + keys: list[expr] + patterns: list[pattern] + rest: str | None + if sys.version_info >= (3, 13): + def __init__( + self, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = None, + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... - class MatchClass(pattern): - __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") - cls: expr - patterns: list[pattern] - kwd_attrs: list[str] - kwd_patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__( - self, - cls: expr, - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, - cls: expr, - patterns: list[pattern], - kwd_attrs: list[str], - kwd_patterns: list[pattern], - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... +class MatchClass(pattern): + __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") + cls: expr + patterns: list[pattern] + kwd_attrs: list[str] + kwd_patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__( + self, + cls: expr, + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, + cls: expr, + patterns: list[pattern], + kwd_attrs: list[str], + kwd_patterns: list[pattern], + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - cls: expr = ..., - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + cls: expr = ..., + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... - class MatchStar(pattern): - __match_args__ = ("name",) - name: str | None - def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchStar(pattern): + __match_args__ = ("name",) + name: str | None + def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchAs(pattern): - __match_args__ = ("pattern", "name") - pattern: ast.pattern | None - name: str | None - def __init__( - self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... +class MatchAs(pattern): + __match_args__ = ("pattern", "name") + pattern: ast.pattern | None + name: str | None + def __init__( + self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] + ) -> Self: ... - class MatchOr(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchOr(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... class type_ignore(AST): ... class TypeIgnore(type_ignore): - if sys.version_info >= (3, 10): - __match_args__ = ("lineno", "tag") + __match_args__ = ("lineno", "tag") lineno: int tag: str def __init__(self, lineno: int, tag: str) -> None: ... @@ -2043,17 +1972,16 @@ class NodeVisitor: def visit_keyword(self, node: keyword) -> Any: ... def visit_alias(self, node: alias) -> Any: ... def visit_withitem(self, node: withitem) -> Any: ... - if sys.version_info >= (3, 10): - def visit_Match(self, node: Match) -> Any: ... - def visit_match_case(self, node: match_case) -> Any: ... - def visit_MatchValue(self, node: MatchValue) -> Any: ... - def visit_MatchSequence(self, node: MatchSequence) -> Any: ... - def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... - def visit_MatchStar(self, node: MatchStar) -> Any: ... - def visit_MatchMapping(self, node: MatchMapping) -> Any: ... - def visit_MatchClass(self, node: MatchClass) -> Any: ... - def visit_MatchAs(self, node: MatchAs) -> Any: ... - def visit_MatchOr(self, node: MatchOr) -> Any: ... + def visit_Match(self, node: Match) -> Any: ... + def visit_match_case(self, node: match_case) -> Any: ... + def visit_MatchValue(self, node: MatchValue) -> Any: ... + def visit_MatchSequence(self, node: MatchSequence) -> Any: ... + def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... + def visit_MatchStar(self, node: MatchStar) -> Any: ... + def visit_MatchMapping(self, node: MatchMapping) -> Any: ... + def visit_MatchClass(self, node: MatchClass) -> Any: ... + def visit_MatchAs(self, node: MatchAs) -> Any: ... + def visit_MatchOr(self, node: MatchOr) -> Any: ... if sys.version_info >= (3, 11): def visit_TryStar(self, node: TryStar) -> Any: ... diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 4f2f45355f5b..56485b8d50e3 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -467,7 +467,7 @@ class AbstractEventLoop: ssl_handshake_timeout: float | None = None, ssl_shutdown_timeout: float | None = None, ) -> tuple[Transport, _ProtocolT]: ... - elif sys.version_info >= (3, 10): + else: async def connect_accepted_socket( self, protocol_factory: Callable[[], _ProtocolT], diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 17390b0c5a0e..4420d02fcd26 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -7,13 +7,8 @@ from types import TracebackType from typing import Any, Literal, TypeVar from typing_extensions import Self -from .events import AbstractEventLoop from .futures import Future - -if sys.version_info >= (3, 10): - from .mixins import _LoopBoundMixin -else: - _LoopBoundMixin = object +from .mixins import _LoopBoundMixin # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): @@ -31,22 +26,14 @@ class _ContextManagerMixin: class Lock(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] | None - if sys.version_info >= (3, 10): - def __init__(self) -> None: ... - else: - def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... class Event(_LoopBoundMixin): _waiters: deque[Future[Any]] - if sys.version_info >= (3, 10): - def __init__(self) -> None: ... - else: - def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... @@ -54,11 +41,7 @@ class Event(_LoopBoundMixin): class Condition(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] - if sys.version_info >= (3, 10): - def __init__(self, lock: Lock | None = None) -> None: ... - else: - def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self, lock: Lock | None = None) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... @@ -70,11 +53,7 @@ class Condition(_ContextManagerMixin, _LoopBoundMixin): class Semaphore(_ContextManagerMixin, _LoopBoundMixin): _value: int _waiters: deque[Future[Any]] | None - if sys.version_info >= (3, 10): - def __init__(self, value: int = 1) -> None: ... - else: - def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self, value: int = 1) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 909d671df289..09c096d40f04 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping from socket import socket from typing import Any, ClassVar, Literal @@ -20,27 +19,16 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr def __del__(self) -> None: ... class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): - if sys.version_info >= (3, 10): - def __init__( - self, - loop: events.AbstractEventLoop, - sock: socket, - protocol: streams.StreamReaderProtocol, - waiter: futures.Future[Any] | None = None, - extra: Mapping[Any, Any] | None = None, - server: events.AbstractServer | None = None, - buffer_size: int = 65536, - ) -> None: ... - else: - def __init__( - self, - loop: events.AbstractEventLoop, - sock: socket, - protocol: streams.StreamReaderProtocol, - waiter: futures.Future[Any] | None = None, - extra: Mapping[Any, Any] | None = None, - server: events.AbstractServer | None = None, - ) -> None: ... + def __init__( + self, + loop: events.AbstractEventLoop, + sock: socket, + protocol: streams.StreamReaderProtocol, + waiter: futures.Future[Any] | None = None, + extra: Mapping[Any, Any] | None = None, + server: events.AbstractServer | None = None, + buffer_size: int = 65536, + ) -> None: ... class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ... class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ... diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index 2fa2226d0e6a..de7c4879d348 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -1,13 +1,9 @@ import sys from _typeshed import SupportsRichComparisonT -from asyncio.events import AbstractEventLoop from types import GenericAlias from typing import Any, Generic, TypeVar -if sys.version_info >= (3, 10): - from .mixins import _LoopBoundMixin -else: - _LoopBoundMixin = object +from .mixins import _LoopBoundMixin class QueueEmpty(Exception): ... class QueueFull(Exception): ... @@ -24,14 +20,8 @@ _T = TypeVar("_T") if sys.version_info >= (3, 13): class QueueShutDown(Exception): ... -# If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy. -# We can remove the noqa pragma when dropping 3.9 support. -class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059 - if sys.version_info >= (3, 10): - def __init__(self, maxsize: int = 0) -> None: ... - else: - def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ... - +class Queue(_LoopBoundMixin, Generic[_T]): + def __init__(self, maxsize: int = 0) -> None: ... def _init(self, maxsize: int) -> None: ... def _get(self) -> _T: ... def _put(self, item: _T) -> None: ... diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 33cffb11ed78..7748cf6d961a 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -28,67 +28,32 @@ _ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awa @type_check_only class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ... -if sys.version_info >= (3, 10): - async def open_connection( - host: str | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_server( - client_connected_cb: _ClientConnectedCallback, - host: str | Sequence[str] | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, - ) -> Server: ... +async def open_connection( + host: str | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, +) -> tuple[StreamReader, StreamWriter]: ... +async def start_server( + client_connected_cb: _ClientConnectedCallback, + host: str | Sequence[str] | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, +) -> Server: ... -else: - async def open_connection( - host: str | None = None, - port: int | str | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, +if sys.platform != "win32": + async def open_unix_connection( + path: StrPath | None = None, *, limit: int = 65536, **kwds: Any ) -> tuple[StreamReader, StreamWriter]: ... - async def start_server( - client_connected_cb: _ClientConnectedCallback, - host: str | None = None, - port: int | str | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, + async def start_unix_server( + client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any ) -> Server: ... -if sys.platform != "win32": - if sys.version_info >= (3, 10): - async def open_unix_connection( - path: StrPath | None = None, *, limit: int = 65536, **kwds: Any - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any - ) -> Server: ... - else: - async def open_unix_connection( - path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, - path: StrPath | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - **kwds: Any, - ) -> Server: ... - class FlowControlMixin(protocols.Protocol): def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ... diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index ceee2b5b90a0..6405e5ae1474 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -101,7 +101,7 @@ if sys.version_info >= (3, 11): pipesize: int = -1, ) -> Process: ... -elif sys.version_info >= (3, 10): +else: async def create_subprocess_shell( cmd: str | bytes, stdin: int | IO[Any] | None = None, @@ -164,67 +164,3 @@ elif sys.version_info >= (3, 10): umask: int = -1, pipesize: int = -1, ) -> Process: ... - -else: # >= 3.9 - async def create_subprocess_shell( - cmd: str | bytes, - stdin: int | IO[Any] | None = None, - stdout: int | IO[Any] | None = None, - stderr: int | IO[Any] | None = None, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - *, - # These parameters are forced to these values by BaseEventLoop.subprocess_shell - universal_newlines: Literal[False] = False, - shell: Literal[True] = True, - bufsize: Literal[0] = 0, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, - # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: StrOrBytesPath | None = None, - preexec_fn: Callable[[], Any] | None = None, - close_fds: bool = True, - cwd: StrOrBytesPath | None = None, - env: subprocess._ENV | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - group: None | str | int = None, - extra_groups: None | Collection[str | int] = None, - user: None | str | int = None, - umask: int = -1, - ) -> Process: ... - async def create_subprocess_exec( - program: StrOrBytesPath, - *args: StrOrBytesPath, - stdin: int | IO[Any] | None = None, - stdout: int | IO[Any] | None = None, - stderr: int | IO[Any] | None = None, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - # These parameters are forced to these values by BaseEventLoop.subprocess_exec - universal_newlines: Literal[False] = False, - shell: Literal[False] = False, - bufsize: Literal[0] = 0, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, - # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: StrOrBytesPath | None = None, - preexec_fn: Callable[[], Any] | None = None, - close_fds: bool = True, - cwd: StrOrBytesPath | None = None, - env: subprocess._ENV | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - group: None | str | int = None, - extra_groups: None | Collection[str | int] = None, - user: None | str | int = None, - umask: int = -1, - ) -> Process: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 06e9f381a89f..aa441d5dd94f 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -92,13 +92,8 @@ if sys.version_info >= (3, 13): def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ... -elif sys.version_info >= (3, 10): - def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... - else: - def as_completed( - fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None - ) -> Iterator[Future[_T]]: ... + def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... @overload def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap] @@ -111,269 +106,131 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No # typing PR #1550 for discussion. # # N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases. -if sys.version_info >= (3, 10): - @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False - ) -> Future[tuple[_T1, _T2]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... - @overload - def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] - @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: bool, - ) -> Future[ - tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] - ]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: bool, - ) -> Future[ - tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - _T6 | BaseException, - ] - ]: ... - @overload - def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... - -else: - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False - ) -> Future[tuple[_T1]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... - @overload - def gather( # type: ignore[overload-overlap] - *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False - ) -> Future[list[_T]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: bool - ) -> Future[tuple[_T1 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[ - tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - _T6 | BaseException, - ] - ]: ... - @overload - def gather( - *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool - ) -> Future[list[_T | BaseException]]: ... +@overload +def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False +) -> Future[tuple[_T1, _T2]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... +@overload +def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] +@overload +def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: bool, +) -> Future[ + tuple[ + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, + _T6 | BaseException, + ] +]: ... +@overload +def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... # unlike some asyncio apis, This does strict runtime checking of actually being a coroutine, not of any future-like. def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... - -if sys.version_info >= (3, 10): - def shield(arg: _FutureLike[_T]) -> Future[_T]: ... - @overload - async def sleep(delay: float) -> None: ... - @overload - async def sleep(delay: float, result: _T) -> _T: ... - async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... - -else: - def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ... - @overload - async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ... - @overload - async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ... - async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ... +def shield(arg: _FutureLike[_T]) -> Future[_T]: ... +@overload +async def sleep(delay: float) -> None: ... +@overload +async def sleep(delay: float, result: _T) -> _T: ... +async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... if sys.version_info >= (3, 11): async def wait( fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[_FT], set[_FT]]: ... -elif sys.version_info >= (3, 10): +else: @overload async def wait( # type: ignore[overload-overlap] fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" @@ -383,24 +240,6 @@ elif sys.version_info >= (3, 10): fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... -else: - @overload - async def wait( # type: ignore[overload-overlap] - fs: Iterable[_FT], - *, - loop: AbstractEventLoop | None = None, - timeout: float | None = None, - return_when: str = "ALL_COMPLETED", - ) -> tuple[set[_FT], set[_FT]]: ... - @overload - async def wait( - fs: Iterable[Awaitable[_T]], - *, - loop: AbstractEventLoop | None = None, - timeout: float | None = None, - return_when: str = "ALL_COMPLETED", - ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... - if sys.version_info >= (3, 12): _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] else: diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 279d74a94ebe..f67c7344d955 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -13,6 +13,8 @@ __all__ = [ "b32decode", "b16encode", "b16decode", + "b32hexencode", + "b32hexdecode", "b85encode", "b85decode", "a85encode", @@ -23,8 +25,6 @@ __all__ = [ "urlsafe_b64decode", ] -if sys.version_info >= (3, 10): - __all__ += ["b32hexencode", "b32hexdecode"] if sys.version_info >= (3, 13): __all__ += ["z85decode", "z85encode"] @@ -38,11 +38,8 @@ def b32encode(s: ReadableBuffer) -> bytes: ... def b32decode(s: str | ReadableBuffer, casefold: bool = False, map01: str | ReadableBuffer | None = None) -> bytes: ... def b16encode(s: ReadableBuffer) -> bytes: ... def b16decode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... - -if sys.version_info >= (3, 10): - def b32hexencode(s: ReadableBuffer) -> bytes: ... - def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... - +def b32hexencode(s: ReadableBuffer) -> bytes: ... +def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... def a85encode( b: ReadableBuffer, *, foldspaces: bool = False, wrapcol: int = 0, pad: bool = False, adobe: bool = False ) -> bytes: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 5657ac74a9ac..a3f9062c68f8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -33,7 +33,7 @@ from _typeshed import ( from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike -from types import CellType, CodeType, GenericAlias, TracebackType +from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType # mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} # are imported from collections.abc in builtins.pyi @@ -143,6 +143,8 @@ class object: @disjoint_base class staticmethod(Generic[_P, _R_co]): + __name__: str + __qualname__: str @property def __func__(self) -> Callable[_P, _R_co]: ... @property @@ -152,18 +154,17 @@ class staticmethod(Generic[_P, _R_co]): def __get__(self, instance: None, owner: type, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[_P, _R_co]: ... - def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... + @property + def __wrapped__(self) -> Callable[_P, _R_co]: ... + def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @disjoint_base class classmethod(Generic[_T, _P, _R_co]): + __name__: str + __qualname__: str @property def __func__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... @property @@ -173,11 +174,8 @@ class classmethod(Generic[_T, _P, _R_co]): def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: None, owner: type[_T], /) -> Callable[_P, _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... + @property + def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @@ -227,11 +225,10 @@ class type: def __subclasscheck__(self, subclass: type, /) -> bool: ... @classmethod def __prepare__(metacls, name: str, bases: tuple[type, ...], /, **kwds: Any) -> MutableMapping[str, object]: ... - if sys.version_info >= (3, 10): - # `int | str` produces an instance of `UnionType`, but `int | int` produces an instance of `type`, - # and `abc.ABC | abc.ABC` produces an instance of `abc.ABCMeta`. - def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... - def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + # `int | str` produces an instance of `UnionType`, but `int | int` produces an instance of `type`, + # and `abc.ABC | abc.ABC` produces an instance of `abc.ABCMeta`. + def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __annotations__: dict[str, AnnotationForm] @@ -268,8 +265,7 @@ class int: def denominator(self) -> Literal[1]: ... def conjugate(self) -> int: ... def bit_length(self) -> int: ... - if sys.version_info >= (3, 10): - def bit_count(self) -> int: ... + def bit_count(self) -> int: ... if sys.version_info >= (3, 11): def to_bytes( @@ -943,11 +939,7 @@ class memoryview(Sequence[_I]): def __setitem__(self, key: slice[SupportsIndex | None], value: ReadableBuffer, /) -> None: ... @overload def __setitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...], value: _I, /) -> None: ... - if sys.version_info >= (3, 10): - def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... - else: - def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ... - + def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... def tolist(self) -> list[int]: ... def toreadonly(self) -> memoryview: ... def release(self) -> None: ... @@ -1086,9 +1078,8 @@ class function: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -1383,20 +1374,18 @@ def bin(number: SupportsIndex, /) -> str: ... def breakpoint(*args: Any, **kws: Any) -> None: ... def callable(obj: object, /) -> TypeIs[Callable[..., object]]: ... def chr(i: SupportsIndex, /) -> str: ... +def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... +@type_check_only +class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): + def __anext__(self) -> _AwaitableT_co: ... -if sys.version_info >= (3, 10): - def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... - @type_check_only - class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): - def __anext__(self) -> _AwaitableT_co: ... - - @overload - # `anext` is not, in fact, an async function. When default is not provided - # `anext` is just a passthrough for `obj.__anext__` - # See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 - def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... - @overload - async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... +@overload +# `anext` is not, in fact, an async function. When default is not provided +# `anext` is just a passthrough for `obj.__anext__` +# See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 +def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... +@overload +async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... # compile() returns a CodeType, unless the flags argument includes PyCF_ONLY_AST (=1024), # in which case it returns ast.AST. We have overloads for flag 0 (the default) and for @@ -1556,10 +1545,7 @@ def iter(object: Callable[[], _T | None], sentinel: None, /) -> Iterator[_T]: .. @overload def iter(object: Callable[[], _T], sentinel: object, /) -> Iterator[_T]: ... -if sys.version_info >= (3, 10): - _ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] -else: - _ClassInfo: TypeAlias = type | tuple[_ClassInfo, ...] +_ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... def issubclass(cls: type, class_or_tuple: _ClassInfo, /) -> bool: ... @@ -1941,83 +1927,45 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... def vars(object: Any = ..., /) -> dict[str, Any]: ... @disjoint_base class zip(Generic[_T_co]): - if sys.version_info >= (3, 10): - @overload - def __new__(cls, *, strict: bool = False) -> zip[Any]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False - ) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - /, - *, - strict: bool = False, - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - /, - *, - strict: bool = False, - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - /, - *iterables: Iterable[Any], - strict: bool = False, - ) -> zip[tuple[Any, ...]]: ... - else: - @overload - def __new__(cls) -> zip[Any]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], /) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], / - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5], / - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - /, - *iterables: Iterable[Any], - ) -> zip[tuple[Any, ...]]: ... - + @overload + def __new__(cls, *, strict: bool = False) -> zip[Any]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False + ) -> zip[tuple[_T1, _T2, _T3]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], /, *, strict: bool = False + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def __new__( + cls, + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + /, + *, + strict: bool = False, + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def __new__( + cls, + iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + /, + *iterables: Iterable[Any], + strict: bool = False, + ) -> zip[tuple[Any, ...]]: ... def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... @@ -2032,29 +1980,12 @@ def __import__( ) -> types.ModuleType: ... def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ... -if sys.version_info >= (3, 10): - from types import EllipsisType, NotImplementedType - - # Backwards compatibility hack for folks who relied on the ellipsis type - # existing in typeshed in Python 3.9 and earlier. - ellipsis = EllipsisType - - Ellipsis: EllipsisType - NotImplemented: NotImplementedType -else: - # Actually the type of Ellipsis is , but since it's - # not exposed anywhere under that name, we make it private here. - @final - @type_check_only - class ellipsis: ... +# Backwards compatibility hack for folks who relied on the ellipsis type +# existing in typeshed in Python 3.9 and earlier. +ellipsis = EllipsisType - Ellipsis: ellipsis - - @final - @type_check_only - class _NotImplementedType(Any): ... - - NotImplemented: _NotImplementedType +Ellipsis: EllipsisType +NotImplemented: NotImplementedType @disjoint_base class BaseException: @@ -2107,15 +2038,11 @@ if sys.platform == "win32": class ArithmeticError(Exception): ... class AssertionError(Exception): ... -if sys.version_info >= (3, 10): - @disjoint_base - class AttributeError(Exception): - def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... - name: str | None - obj: object - -else: - class AttributeError(Exception): ... +@disjoint_base +class AttributeError(Exception): + def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... + name: str | None + obj: object class BufferError(Exception): ... class EOFError(Exception): ... @@ -2132,14 +2059,10 @@ class ImportError(Exception): class LookupError(Exception): ... class MemoryError(Exception): ... -if sys.version_info >= (3, 10): - @disjoint_base - class NameError(Exception): - def __init__(self, *args: object, name: str | None = None) -> None: ... - name: str | None - -else: - class NameError(Exception): ... +@disjoint_base +class NameError(Exception): + def __init__(self, *args: object, name: str | None = None) -> None: ... + name: str | None class ReferenceError(Exception): ... class RuntimeError(Exception): ... @@ -2155,9 +2078,8 @@ class SyntaxError(Exception): # Errors are displayed differently if this attribute exists on the exception. # The value is always None. print_file_and_line: None - if sys.version_info >= (3, 10): - end_lineno: int | None - end_offset: int | None + end_lineno: int | None + end_offset: int | None @overload def __init__(self) -> None: ... @@ -2166,12 +2088,11 @@ class SyntaxError(Exception): # Second argument is the tuple (filename, lineno, offset, text) @overload def __init__(self, msg: str, info: tuple[str | None, int | None, int | None, str | None], /) -> None: ... - if sys.version_info >= (3, 10): - # end_lineno and end_offset must both be provided if one is. - @overload - def __init__( - self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / - ) -> None: ... + # end_lineno and end_offset must both be provided if one is. + @overload + def __init__( + self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / + ) -> None: ... # If you provide more than two arguments, it still creates the SyntaxError, but # the arguments from the info tuple are not parsed. This form is omitted. @@ -2247,9 +2168,7 @@ class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... - -if sys.version_info >= (3, 10): - class EncodingWarning(Warning): ... +class EncodingWarning(Warning): ... if sys.version_info >= (3, 11): _BaseExceptionT_co = TypeVar("_BaseExceptionT_co", bound=BaseException, covariant=True, default=BaseException) diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index f8297a7dca93..cd54c5e4393d 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -8,6 +8,13 @@ from typing import ClassVar, Final from typing_extensions import TypeAlias __all__ = [ + "FRIDAY", + "MONDAY", + "SATURDAY", + "SUNDAY", + "THURSDAY", + "TUESDAY", + "WEDNESDAY", "IllegalMonthError", "IllegalWeekdayError", "setfirstweekday", @@ -34,8 +41,6 @@ __all__ = [ "weekheader", ] -if sys.version_info >= (3, 10): - __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] if sys.version_info >= (3, 12): __all__ += [ "Day", diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 95f13b0c8dd2..72007a15093e 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,26 +1,22 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT +from collections.abc import ( + Callable, + ItemsView, + Iterable, + Iterator, + KeysView, + Mapping, + MutableMapping, + MutableSequence, + Sequence, + ValuesView, +) from types import GenericAlias from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only from typing_extensions import Self, disjoint_base -if sys.version_info >= (3, 10): - from collections.abc import ( - Callable, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - Sequence, - ValuesView, - ) -else: - from _collections_abc import * - __all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"] _S = TypeVar("_S") @@ -303,12 +299,15 @@ class Counter(dict[_T, int], Generic[_T]): def update(self, iterable: Iterable[_T], /, **kwargs: int) -> None: ... @overload def update(self, iterable: None = None, /, **kwargs: int) -> None: ... + def total(self) -> int: ... def __missing__(self, key: _T) -> int: ... def __delitem__(self, elem: object) -> None: ... - if sys.version_info >= (3, 10): - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + def __le__(self, other: Counter[Any]) -> bool: ... + def __lt__(self, other: Counter[Any]) -> bool: ... + def __ge__(self, other: Counter[Any]) -> bool: ... + def __gt__(self, other: Counter[Any]) -> bool: ... def __add__(self, other: Counter[_S]) -> Counter[_T | _S]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... def __and__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -320,12 +319,6 @@ class Counter(dict[_T, int], Generic[_T]): def __isub__(self, other: SupportsItems[_T, int]) -> Self: ... def __iand__(self, other: SupportsItems[_T, int]) -> Self: ... def __ior__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[override,misc] - if sys.version_info >= (3, 10): - def total(self) -> int: ... - def __le__(self, other: Counter[Any]) -> bool: ... - def __lt__(self, other: Counter[Any]) -> bool: ... - def __ge__(self, other: Counter[Any]) -> bool: ... - def __gt__(self, other: Counter[Any]) -> bool: ... # The pure-Python implementations of the "views" classes # These are exposed at runtime in `collections/__init__.py` diff --git a/stdlib/compileall.pyi b/stdlib/compileall.pyi index 8972d50a4a63..49a4c69dd3fb 100644 --- a/stdlib/compileall.pyi +++ b/stdlib/compileall.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import StrPath from py_compile import PycInvalidationMode from typing import Any, Protocol, type_check_only @@ -9,74 +8,38 @@ __all__ = ["compile_dir", "compile_file", "compile_path"] class _SupportsSearch(Protocol): def search(self, string: str, /) -> Any: ... -if sys.version_info >= (3, 10): - def compile_dir( - dir: StrPath, - maxlevels: int | None = None, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - workers: int = 1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - def compile_file( - fullname: StrPath, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - -else: - def compile_dir( - dir: StrPath, - maxlevels: int | None = None, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - workers: int = 1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: str | None = None, # https://bugs.python.org/issue40447 - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - def compile_file( - fullname: StrPath, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: str | None = None, # https://bugs.python.org/issue40447 - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - +def compile_dir( + dir: StrPath, + maxlevels: int | None = None, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + workers: int = 1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, +) -> bool: ... +def compile_file( + fullname: StrPath, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, +) -> bool: ... def compile_path( skip_curdir: bool = ..., maxlevels: int = 0, diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index dff34474d2f5..bb6facb5a349 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -8,6 +8,7 @@ from typing import Any, Generic, Protocol, TypeVar, overload, runtime_checkable, from typing_extensions import ParamSpec, Self, TypeAlias, deprecated __all__ = [ + "aclosing", "contextmanager", "closing", "AbstractContextManager", @@ -22,9 +23,6 @@ __all__ = [ "nullcontext", ] -if sys.version_info >= (3, 10): - __all__ += ["aclosing"] - if sys.version_info >= (3, 11): __all__ += ["chdir"] @@ -94,29 +92,20 @@ def contextmanager(func: Callable[_P, Generator[_T_co, None, object]]) -> Callab ) def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ... -if sys.version_info >= (3, 10): - _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) - - class AsyncContextDecorator: - def _recreate_cm(self) -> Self: ... - def __call__(self, func: _AF) -> _AF: ... - - class _AsyncGeneratorContextManager( - _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], - AbstractAsyncContextManager[_T_co, bool | None], - AsyncContextDecorator, - ): - async def __aexit__( - self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... - -else: - class _AsyncGeneratorContextManager( - _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], AbstractAsyncContextManager[_T_co, bool | None] - ): - async def __aexit__( - self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... +_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) + +class AsyncContextDecorator: + def _recreate_cm(self) -> Self: ... + def __call__(self, func: _AF) -> _AF: ... + +class _AsyncGeneratorContextManager( + _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], + AbstractAsyncContextManager[_T_co, bool | None], + AsyncContextDecorator, +): + async def __aexit__( + self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... @overload def asynccontextmanager(func: Callable[_P, AsyncGenerator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... @@ -136,16 +125,15 @@ class closing(AbstractContextManager[_SupportsCloseT, None]): def __init__(self, thing: _SupportsCloseT) -> None: ... def __exit__(self, *exc_info: Unused) -> None: ... -if sys.version_info >= (3, 10): - @type_check_only - class _SupportsAclose(Protocol): - def aclose(self) -> Awaitable[object]: ... +@type_check_only +class _SupportsAclose(Protocol): + def aclose(self) -> Awaitable[object]: ... - _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) +_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) - class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): - def __init__(self, thing: _SupportsAcloseT) -> None: ... - async def __aexit__(self, *exc_info: Unused) -> None: ... +class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): + def __init__(self, thing: _SupportsAcloseT) -> None: ... + async def __aexit__(self, *exc_info: Unused) -> None: ... class suppress(AbstractContextManager[None, bool]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -212,27 +200,16 @@ class AsyncExitStack(_BaseExitStackAbstract[_ExitT_co]): self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, / ) -> _ExitT_co: ... -if sys.version_info >= (3, 10): - class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): - enter_result: _T - @overload - def __init__(self: nullcontext[None]) -> None: ... - @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 - def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... - async def __aenter__(self) -> _T: ... - async def __aexit__(self, *exctype: Unused) -> None: ... - -else: - class nullcontext(AbstractContextManager[_T, None]): - enter_result: _T - @overload - def __init__(self: nullcontext[None]) -> None: ... - @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 - def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... +class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): + enter_result: _T + @overload + def __init__(self: nullcontext[None]) -> None: ... + @overload + def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 + def __enter__(self) -> _T: ... + def __exit__(self, *exctype: Unused) -> None: ... + async def __aenter__(self) -> _T: ... + async def __aexit__(self, *exctype: Unused) -> None: ... if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath) diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 2c8e7109cdfc..24c1c54bba5a 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -19,11 +19,7 @@ from _csv import ( if sys.version_info >= (3, 12): from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS -if sys.version_info >= (3, 10): - from _csv import Reader, Writer -else: - from _csv import _reader as Reader, _writer as Writer - +from _csv import Reader, Writer from _typeshed import SupportsWrite from collections.abc import Collection, Iterable, Mapping, Sequence from types import GenericAlias diff --git a/stdlib/curses/__init__.pyi b/stdlib/curses/__init__.pyi index 3e32487ad99f..1d725fa6f281 100644 --- a/stdlib/curses/__init__.pyi +++ b/stdlib/curses/__init__.pyi @@ -1,4 +1,3 @@ -import sys from _curses import * from _curses import window as window from _typeshed import structseq @@ -30,8 +29,7 @@ def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwd @final @type_check_only class _ncurses_version(structseq[int], tuple[int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("major", "minor", "patch") + __match_args__: Final = ("major", "minor", "patch") @property def major(self) -> int: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 3a1c8cb5d62d..f24ff6a3dd50 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -17,6 +17,7 @@ __all__ = [ "Field", "FrozenInstanceError", "InitVar", + "KW_ONLY", "MISSING", "fields", "asdict", @@ -26,9 +27,6 @@ __all__ = [ "is_dataclass", ] -if sys.version_info >= (3, 10): - __all__ += ["KW_ONLY"] - _DataclassT = TypeVar("_DataclassT", bound=DataclassInstance) @type_check_only @@ -60,8 +58,7 @@ class _MISSING_TYPE(enum.Enum): MISSING: Final = _MISSING_TYPE.MISSING -if sys.version_info >= (3, 10): - class KW_ONLY: ... +class KW_ONLY: ... @overload def asdict(obj: DataclassInstance) -> dict[str, Any]: ... @@ -106,7 +103,7 @@ if sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... -elif sys.version_info >= (3, 10): +else: @overload def dataclass( cls: type[_T], @@ -138,32 +135,6 @@ elif sys.version_info >= (3, 10): slots: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... -else: - @overload - def dataclass( - cls: type[_T], - /, - *, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> type[_T]: ... - @overload - def dataclass( - cls: None = None, - /, - *, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> Callable[[type[_T]], type[_T]]: ... - # See https://github.com/python/mypy/issues/10750 @type_check_only class _DefaultFactory(Protocol[_T_co]): @@ -185,7 +156,7 @@ class Field(Generic[_T]): "doc", "_field_type", ) - elif sys.version_info >= (3, 10): + else: __slots__ = ( "name", "type", @@ -199,8 +170,6 @@ class Field(Generic[_T]): "kw_only", "_field_type", ) - else: - __slots__ = ("name", "type", "default", "default_factory", "repr", "hash", "init", "compare", "metadata", "_field_type") name: str type: Type[_T] | str | Any default: _T | Literal[_MISSING_TYPE.MISSING] @@ -214,8 +183,7 @@ class Field(Generic[_T]): if sys.version_info >= (3, 14): doc: str | None - if sys.version_info >= (3, 10): - kw_only: bool | Literal[_MISSING_TYPE.MISSING] + kw_only: bool | Literal[_MISSING_TYPE.MISSING] if sys.version_info >= (3, 14): def __init__( @@ -230,18 +198,6 @@ class Field(Generic[_T]): kw_only: bool, doc: str | None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - default: _T, - default_factory: Callable[[], _T], - init: bool, - repr: bool, - hash: bool | None, - compare: bool, - metadata: Mapping[Any, Any], - kw_only: bool, - ) -> None: ... else: def __init__( self, @@ -252,6 +208,7 @@ class Field(Generic[_T]): hash: bool | None, compare: bool, metadata: Mapping[Any, Any], + kw_only: bool, ) -> None: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... @@ -300,7 +257,7 @@ if sys.version_info >= (3, 14): doc: str | None = None, ) -> Any: ... -elif sys.version_info >= (3, 10): +else: @overload # `default` and `default_factory` are optional and mutually exclusive. def field( *, @@ -338,41 +295,6 @@ elif sys.version_info >= (3, 10): kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ..., ) -> Any: ... -else: - @overload # `default` and `default_factory` are optional and mutually exclusive. - def field( - *, - default: _T, - default_factory: Literal[_MISSING_TYPE.MISSING] = ..., - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> _T: ... - @overload - def field( - *, - default: Literal[_MISSING_TYPE.MISSING] = ..., - default_factory: Callable[[], _T], - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> _T: ... - @overload - def field( - *, - default: Literal[_MISSING_TYPE.MISSING] = ..., - default_factory: Literal[_MISSING_TYPE.MISSING] = ..., - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> Any: ... - def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ... # HACK: `obj: Never` typing matches if object argument is using `Any` type. @@ -454,7 +376,7 @@ elif sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> type: ... -elif sys.version_info >= (3, 10): +else: def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], @@ -472,19 +394,4 @@ elif sys.version_info >= (3, 10): slots: bool = False, ) -> type: ... -else: - def make_dataclass( - cls_name: str, - fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], - *, - bases: tuple[type, ...] = (), - namespace: dict[str, Any] | None = None, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> type: ... - def replace(obj: _DataclassT, /, **changes: Any) -> _DataclassT: ... diff --git a/stdlib/distutils/command/__init__.pyi b/stdlib/distutils/command/__init__.pyi index 4d7372858af3..856c5eb8b44a 100644 --- a/stdlib/distutils/command/__init__.pyi +++ b/stdlib/distutils/command/__init__.pyi @@ -1,5 +1,3 @@ -import sys - from . import ( bdist, bdist_dumb, @@ -41,8 +39,3 @@ __all__ = [ "check", "upload", ] - -if sys.version_info < (3, 10): - from . import bdist_wininst - - __all__ += ["bdist_wininst"] diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 1714e01a2c28..7e11cf257c2c 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete from collections.abc import Callable from typing import Any, ClassVar, Final, Literal @@ -10,9 +9,6 @@ HAS_USER_SITE: Final[bool] SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] -if sys.version_info < (3, 10): - WINDOWS_SCHEME: Final[dict[str, str]] - class install(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 4a9c45eb562a..0ed567b98d74 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping from distutils.ccompiler import CCompiler from typing import Final, Literal, overload @@ -28,6 +27,3 @@ def get_python_lib( plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = None ) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... - -if sys.version_info < (3, 10): - def get_python_version() -> str: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index a6d7c48d69cd..e75e7ba1cf06 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -17,18 +17,17 @@ TOKEN_ENDS: Final[set[str]] ASPECIALS: Final[set[str]] ATTRIBUTE_ENDS: Final[set[str]] EXTENDED_ATTRIBUTE_ENDS: Final[set[str]] -# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5 +# Added in Python 3.10.15, 3.11.10, 3.12.5 NLSET: Final[set[str]] -# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5 +# Added in Python 3.10.15, 3.11.10, 3.12.5 SPECIALSNL: Final[set[str]] -# Added in Python 3.9.23, 3.10.17, 3.11.12, 3.12.9, 3.13.2 +# Added in Python 3.10.17, 3.11.12, 3.12.9, 3.13.2 def make_quoted_pairs(value: Any) -> str: ... def quote_string(value: Any) -> str: ... -if sys.version_info >= (3, 10): - # Added in Python 3.10.20, 3.11.15, 3.12.13, 3.13.12, 3.14.3 - def make_parenthesis_pairs(value: Any) -> str: ... +# Added in Python 3.10.20, 3.11.15, 3.12.13, 3.13.12, 3.14.3 +def make_parenthesis_pairs(value: Any) -> str: ... rfc2047_matcher: Final[Pattern[str]] diff --git a/stdlib/email/errors.pyi b/stdlib/email/errors.pyi index b501a5866556..4da60250965e 100644 --- a/stdlib/email/errors.pyi +++ b/stdlib/email/errors.pyi @@ -1,5 +1,3 @@ -import sys - class MessageError(Exception): ... class MessageParseError(MessageError): ... class HeaderParseError(MessageParseError): ... @@ -37,6 +35,4 @@ class NonPrintableDefect(HeaderDefect): class ObsoleteHeaderDefect(HeaderDefect): ... class NonASCIILocalPartDefect(HeaderDefect): ... - -if sys.version_info >= (3, 10): - class InvalidDateDefect(HeaderDefect): ... +class InvalidDateDefect(HeaderDefect): ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index f9b53e1d45f1..2afeda37996c 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -114,10 +114,8 @@ class EnumMeta(type): def __contains__(self: type[Any], value: object) -> bool: ... elif sys.version_info >= (3, 11): def __contains__(self: type[Any], member: object) -> bool: ... - elif sys.version_info >= (3, 10): - def __contains__(self: type[Any], obj: object) -> bool: ... else: - def __contains__(self: type[Any], member: object) -> bool: ... + def __contains__(self: type[Any], obj: object) -> bool: ... def __getitem__(self: type[_EnumMemberT], name: str) -> _EnumMemberT: ... @_builtins_property diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 5a3e89b0c676..d58ad309e5a2 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -45,11 +45,8 @@ if sys.platform != "win32": F_OFD_GETLK: Final[int] F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int] - - if sys.version_info >= (3, 10): - F_GETPIPE_SZ: Final[int] - F_SETPIPE_SZ: Final[int] - + F_GETPIPE_SZ: Final[int] + F_SETPIPE_SZ: Final[int] DN_ACCESS: Final[int] DN_ATTRIB: Final[int] DN_CREATE: Final[int] diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 6778b764810b..41b20268afa8 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -30,10 +30,54 @@ class _HasReadlineAndFileno(Protocol[AnyStr_co]): def readline(self) -> AnyStr_co: ... def fileno(self) -> int: ... -if sys.version_info >= (3, 10): +# encoding and errors are added +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: _TextMode = "r", + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, + encoding: str | None = None, + errors: str | None = None, +) -> FileInput[str]: ... +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: Literal["rb"], + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, + encoding: None = None, + errors: None = None, +) -> FileInput[bytes]: ... +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: str, + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, + encoding: str | None = None, + errors: str | None = None, +) -> FileInput[Any]: ... +def close() -> None: ... +def nextfile() -> None: ... +def filename() -> str: ... +def lineno() -> int: ... +def filelineno() -> int: ... +def fileno() -> int: ... +def isfirstline() -> bool: ... +def isstdin() -> bool: ... + +class FileInput(Generic[AnyStr]): # encoding and errors are added @overload - def input( + def __init__( + self: FileInput[str], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -42,9 +86,10 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> FileInput[str]: ... + ) -> None: ... @overload - def input( + def __init__( + self: FileInput[bytes], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -53,9 +98,10 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, encoding: None = None, errors: None = None, - ) -> FileInput[bytes]: ... + ) -> None: ... @overload - def input( + def __init__( + self: FileInput[Any], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -64,120 +110,7 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> FileInput[Any]: ... - -else: - # bufsize is dropped and mode and openhook become keyword-only - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - ) -> FileInput[str]: ... - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - ) -> FileInput[bytes]: ... - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - ) -> FileInput[Any]: ... - -def close() -> None: ... -def nextfile() -> None: ... -def filename() -> str: ... -def lineno() -> int: ... -def filelineno() -> int: ... -def fileno() -> int: ... -def isfirstline() -> bool: ... -def isstdin() -> bool: ... - -class FileInput(Generic[AnyStr]): - if sys.version_info >= (3, 10): - # encoding and errors are added - @overload - def __init__( - self: FileInput[str], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - encoding: str | None = None, - errors: str | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[bytes], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - encoding: None = None, - errors: None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[Any], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - encoding: str | None = None, - errors: str | None = None, - ) -> None: ... - - else: - # bufsize is dropped and mode and openhook become keyword-only - @overload - def __init__( - self: FileInput[str], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[bytes], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[Any], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - ) -> None: ... - + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... def __enter__(self) -> Self: ... @@ -199,17 +132,8 @@ class FileInput(Generic[AnyStr]): def isstdin(self) -> bool: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -if sys.version_info >= (3, 10): - def hook_compressed( - filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None - ) -> IO[Any]: ... - -else: - def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ... - -if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") - def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... - -else: - def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... +def hook_compressed( + filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None +) -> IO[Any]: ... +@deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") +def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 942fd7396196..07455acaefc6 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -9,19 +9,14 @@ __all__ = ["escape", "glob", "iglob"] if sys.version_info >= (3, 13): __all__ += ["translate"] -if sys.version_info >= (3, 10): - @deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." - ) - def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - @deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." - ) - def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - -else: - def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... +@deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." +) +def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... +@deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." +) +def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... if sys.version_info >= (3, 11): def glob( @@ -41,7 +36,7 @@ if sys.version_info >= (3, 11): include_hidden: bool = False, ) -> Iterator[AnyStr]: ... -elif sys.version_info >= (3, 10): +else: def glob( pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> list[AnyStr]: ... @@ -49,10 +44,6 @@ elif sys.version_info >= (3, 10): pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> Iterator[AnyStr]: ... -else: - def glob(pathname: AnyStr, *, recursive: bool = False) -> list[AnyStr]: ... - def iglob(pathname: AnyStr, *, recursive: bool = False) -> Iterator[AnyStr]: ... - def escape(pathname: AnyStr) -> AnyStr: ... def has_magic(s: str | bytes) -> bool: ... # undocumented diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 965ecece2a56..9f372b4d63dc 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -5,8 +5,7 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") + __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") @property def gr_name(self) -> str: ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 31e1d3fc8378..8be4ce5e3d2c 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import StrPath from collections.abc import Iterator, Sequence from http.client import HTTPResponse @@ -49,9 +48,7 @@ class FileCookieJar(CookieJar): def load(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... def revert(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... -class MozillaCookieJar(FileCookieJar): - if sys.version_info < (3, 10): - header: ClassVar[str] # undocumented +class MozillaCookieJar(FileCookieJar): ... class LWPCookieJar(FileCookieJar): def as_lwp_str(self, ignore_discard: bool = True, ignore_expires: bool = True) -> str: ... # undocumented diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index 90ab34021917..e8c80c0447ae 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -4,17 +4,16 @@ 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. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(self, module: types.ModuleType) -> str: ... +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." + ) + def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - def exec_module(self, module: types.ModuleType) -> None: ... + def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... + # Not defined on the actual class for backwards-compatibility reasons, + # but expected in new code. + def exec_module(self, module: types.ModuleType) -> None: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index ef7761f7119b..b4fa8d9234a3 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -5,6 +5,7 @@ from _typeshed import ReadableBuffer, StrPath from abc import ABCMeta, abstractmethod from collections.abc import Iterator, Mapping, Sequence from importlib import _bootstrap_external +from importlib._abc import Loader as Loader from importlib.machinery import ModuleSpec from io import BufferedReader from typing import IO, Any, Literal, Protocol, overload, runtime_checkable @@ -25,17 +26,6 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): __all__ += ["Finder", "ResourceReader", "Traversable", "TraversableResources"] -if sys.version_info >= (3, 10): - from importlib._abc import Loader as Loader -else: - class Loader(metaclass=ABCMeta): - def load_module(self, fullname: str) -> types.ModuleType: ... - def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - 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): ... @@ -67,47 +57,28 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo def get_source(self, fullname: str) -> str | None: ... def path_stats(self, path: str) -> Mapping[str, Any]: ... -# The base classes differ starting in 3.10: -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: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / - ) -> ModuleSpec | None: ... - - 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: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... - -else: - # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol - class MetaPathFinder(Finder): +# 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: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / - ) -> ModuleSpec | None: ... - class PathEntryFinder(Finder): + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec( + self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / + ) -> ModuleSpec | None: ... + +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: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... + + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... class FileLoader(_bootstrap_external.FileLoader, ResourceLoader, ExecutionLoader, metaclass=ABCMeta): name: str @@ -123,13 +94,8 @@ if sys.version_info < (3, 11): def open_resource(self, resource: str) -> IO[bytes]: ... @abstractmethod def resource_path(self, resource: str) -> str: ... - if sys.version_info >= (3, 10): - @abstractmethod - def is_resource(self, path: str) -> bool: ... - else: - @abstractmethod - def is_resource(self, name: str) -> bool: ... - + @abstractmethod + def is_resource(self, path: str) -> bool: ... @abstractmethod def contents(self) -> Iterator[str]: ... @@ -160,12 +126,7 @@ if sys.version_info < (3, 11): @property @abstractmethod def name(self) -> str: ... - if sys.version_info >= (3, 10): - def __truediv__(self, child: str, /) -> Traversable: ... - else: - @abstractmethod - def __truediv__(self, child: str, /) -> Traversable: ... - + def __truediv__(self, child: str, /) -> Traversable: ... @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index bb1b22f11a62..2306724d7034 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -5,10 +5,9 @@ import types from _collections_abc import dict_keys, dict_values from _typeshed import StrPath from collections.abc import Iterable, Iterator, Mapping -from email.message import Message from importlib.abc import MetaPathFinder +from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath from os import PathLike -from pathlib import Path from re import Pattern from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload, type_check_only from typing_extensions import Self, TypeAlias, deprecated, disjoint_base @@ -20,27 +19,21 @@ _VT = TypeVar("_VT") __all__ = [ "Distribution", "DistributionFinder", + "PackageMetadata", "PackageNotFoundError", "distribution", "distributions", "entry_points", "files", "metadata", + "packages_distributions", "requires", "version", ] -if sys.version_info >= (3, 10): - __all__ += ["PackageMetadata", "packages_distributions"] +_SimplePath: TypeAlias = SimplePath -if sys.version_info >= (3, 10): - from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath - def packages_distributions() -> Mapping[str, list[str]]: ... - - _SimplePath: TypeAlias = SimplePath - -else: - _SimplePath: TypeAlias = Path +def packages_distributions() -> Mapping[str, list[str]]: ... class PackageNotFoundError(ModuleNotFoundError): @property @@ -104,19 +97,17 @@ else: def module(self) -> str: ... @property def attr(self) -> str: ... - if sys.version_info >= (3, 10): - dist: ClassVar[Distribution | None] - def matches( - self, - *, - name: str = ..., - value: str = ..., - group: str = ..., - module: str = ..., - attr: str = ..., - extras: list[str] = ..., - ) -> bool: ... # undocumented - + dist: ClassVar[Distribution | None] + def matches( + self, + *, + name: str = ..., + value: str = ..., + group: str = ..., + module: str = ..., + attr: str = ..., + extras: list[str] = ..., + ) -> bool: ... # undocumented def __hash__(self) -> int: ... def __iter__(self) -> Iterator[Any]: ... # result of iter((str, Self)), really @@ -139,7 +130,7 @@ if sys.version_info >= (3, 12): @property def groups(self) -> set[str]: ... -elif sys.version_info >= (3, 10): +else: class DeprecatedList(list[_T]): __slots__ = () @@ -162,7 +153,7 @@ elif sys.version_info >= (3, 10): @property def groups(self) -> set[str]: ... -if sys.version_info >= (3, 10) and sys.version_info < (3, 12): +if sys.version_info < (3, 12): class Deprecated(Generic[_KT, _VT]): def __getitem__(self, name: _KT) -> _VT: ... @overload @@ -235,27 +226,18 @@ class Distribution(_distribution_parent): ) -> Iterable[Distribution]: ... @staticmethod def at(path: StrPath) -> PathDistribution: ... - - if sys.version_info >= (3, 10): - @property - def metadata(self) -> PackageMetadata: ... - @property - def entry_points(self) -> EntryPoints: ... - else: - @property - def metadata(self) -> Message: ... - @property - def entry_points(self) -> list[EntryPoint]: ... - + @property + def metadata(self) -> PackageMetadata: ... + @property + def entry_points(self) -> EntryPoints: ... @property def version(self) -> str: ... @property def files(self) -> list[PackagePath] | None: ... @property def requires(self) -> list[str] | None: ... - if sys.version_info >= (3, 10): - @property - def name(self) -> str: ... + @property + def name(self) -> str: ... if sys.version_info >= (3, 13): @property def origin(self) -> types.SimpleNamespace | None: ... @@ -276,7 +258,7 @@ class MetadataPathFinder(DistributionFinder): if sys.version_info >= (3, 11): @classmethod def invalidate_caches(cls) -> None: ... - elif sys.version_info >= (3, 10): + else: # Yes, this is an instance method that has a parameter named "cls" def invalidate_caches(cls) -> None: ... @@ -293,19 +275,14 @@ def distributions(*, context: DistributionFinder.Context) -> Iterable[Distributi def distributions( *, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any ) -> Iterable[Distribution]: ... - -if sys.version_info >= (3, 10): - def metadata(distribution_name: str) -> PackageMetadata: ... - -else: - def metadata(distribution_name: str) -> Message: ... +def metadata(distribution_name: str) -> PackageMetadata: ... if sys.version_info >= (3, 12): def entry_points( *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... -elif sys.version_info >= (3, 10): +else: @overload def entry_points() -> SelectableGroups: ... @overload @@ -313,9 +290,6 @@ elif sys.version_info >= (3, 10): *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... -else: - def entry_points() -> dict[str, list[EntryPoint]]: ... - def version(distribution_name: str) -> str: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/importlib/readers.pyi b/stdlib/importlib/readers.pyi index 0e7f7ce165c3..50f06ea5434d 100644 --- a/stdlib/importlib/readers.pyi +++ b/stdlib/importlib/readers.pyi @@ -7,66 +7,63 @@ import sys import zipfile from _typeshed import StrPath from collections.abc import Iterable, Iterator +from importlib._bootstrap_external import FileLoader from io import BufferedReader from typing import Literal, NoReturn, TypeVar from typing_extensions import Never - -if sys.version_info >= (3, 10): - from importlib._bootstrap_external import FileLoader - from zipimport import zipimporter +from zipimport import zipimporter if sys.version_info >= (3, 11): from importlib.resources import abc else: from importlib import abc -if sys.version_info >= (3, 10): - if sys.version_info >= (3, 11): - __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] +if sys.version_info >= (3, 11): + __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] - if sys.version_info < (3, 11): - _T = TypeVar("_T") +if sys.version_info < (3, 11): + _T = TypeVar("_T") - def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... + def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... - class FileReader(abc.TraversableResources): - path: pathlib.Path - def __init__(self, loader: FileLoader) -> None: ... - def resource_path(self, resource: StrPath) -> str: ... - def files(self) -> pathlib.Path: ... +class FileReader(abc.TraversableResources): + path: pathlib.Path + def __init__(self, loader: FileLoader) -> None: ... + def resource_path(self, resource: StrPath) -> str: ... + def files(self) -> pathlib.Path: ... - class ZipReader(abc.TraversableResources): - prefix: str - archive: str - def __init__(self, loader: zipimporter, module: str) -> None: ... - def open_resource(self, resource: str) -> BufferedReader: ... - def is_resource(self, path: StrPath) -> bool: ... - def files(self) -> zipfile.Path: ... +class ZipReader(abc.TraversableResources): + prefix: str + archive: str + def __init__(self, loader: zipimporter, module: str) -> None: ... + def open_resource(self, resource: str) -> BufferedReader: ... + def is_resource(self, path: StrPath) -> bool: ... + def files(self) -> zipfile.Path: ... - class MultiplexedPath(abc.Traversable): - def __init__(self, *paths: abc.Traversable) -> None: ... - def iterdir(self) -> Iterator[abc.Traversable]: ... - def read_bytes(self) -> NoReturn: ... - def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - def is_dir(self) -> Literal[True]: ... - def is_file(self) -> Literal[False]: ... +class MultiplexedPath(abc.Traversable): + def __init__(self, *paths: abc.Traversable) -> None: ... + def iterdir(self) -> Iterator[abc.Traversable]: ... + def read_bytes(self) -> NoReturn: ... + def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + def is_dir(self) -> Literal[True]: ... + def is_file(self) -> Literal[False]: ... - if sys.version_info >= (3, 12): - def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... - elif sys.version_info >= (3, 11): - def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] - else: - def joinpath(self, child: str) -> abc.Traversable: ... + if sys.version_info >= (3, 12): + def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... + elif sys.version_info >= (3, 11): + def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] + else: + def joinpath(self, child: str) -> abc.Traversable: ... - if sys.version_info < (3, 12): - __truediv__ = joinpath + if sys.version_info < (3, 12): + __truediv__ = joinpath - def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - @property - def name(self) -> str: ... + def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + @property + def name(self) -> str: ... - class NamespaceReader(abc.TraversableResources): - path: MultiplexedPath - def __init__(self, namespace_path: Iterable[str]) -> None: ... - def resource_path(self, resource: str) -> str: ... - def files(self) -> MultiplexedPath: ... +class NamespaceReader(abc.TraversableResources): + path: MultiplexedPath + def __init__(self, namespace_path: Iterable[str]) -> None: ... + def resource_path(self, resource: str) -> str: ... + def files(self) -> MultiplexedPath: ... diff --git a/stdlib/importlib/resources/__init__.pyi b/stdlib/importlib/resources/__init__.pyi index 28adc37da4a4..695bec8849c5 100644 --- a/stdlib/importlib/resources/__init__.pyi +++ b/stdlib/importlib/resources/__init__.pyi @@ -19,6 +19,7 @@ else: __all__ = [ "Package", + "ResourceReader", "as_file", "contents", "files", @@ -30,9 +31,6 @@ __all__ = [ "read_text", ] -if sys.version_info >= (3, 10): - __all__ += ["ResourceReader"] - if sys.version_info < (3, 13): __all__ += ["Resource"] @@ -82,5 +80,5 @@ else: if sys.version_info >= (3, 11): from importlib.resources.abc import ResourceReader as ResourceReader -elif sys.version_info >= (3, 10): +else: from importlib.abc import ResourceReader as ResourceReader diff --git a/stdlib/importlib/resources/_common.pyi b/stdlib/importlib/resources/_common.pyi index 11a93ca82d8d..fdd7124f7521 100644 --- a/stdlib/importlib/resources/_common.pyi +++ b/stdlib/importlib/resources/_common.pyi @@ -16,7 +16,7 @@ if sys.version_info >= (3, 11): Anchor: TypeAlias = Package def package_to_anchor( - func: Callable[[Anchor | None], Traversable], + func: Callable[[Anchor | None], Traversable] ) -> Callable[[Anchor | None, Anchor | None], Traversable]: ... @overload def files(anchor: Anchor | None = None) -> Traversable: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index c48d63bc4f32..f67ea3699831 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -319,7 +319,7 @@ if sys.version_info >= (3, 14): annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Signature: ... -elif sys.version_info >= (3, 10): +else: def signature( obj: _IntrospectableCallable, *, @@ -329,9 +329,6 @@ elif sys.version_info >= (3, 10): eval_str: bool = False, ) -> Signature: ... -else: - def signature(obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Signature: ... - class _void: ... class _empty: ... @@ -361,7 +358,7 @@ class Signature: eval_str: bool = False, annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Self: ... - elif sys.version_info >= (3, 10): + else: @classmethod def from_callable( cls, @@ -372,9 +369,6 @@ class Signature: locals: Mapping[str, Any] | None = None, eval_str: bool = False, ) -> Self: ... - else: - @classmethod - def from_callable(cls, obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Self: ... if sys.version_info >= (3, 14): def format(self, *, max_width: int | None = None, quote_annotation_strings: bool = True) -> str: ... elif sys.version_info >= (3, 13): @@ -385,7 +379,7 @@ class Signature: if sys.version_info >= (3, 14): from annotationlib import get_annotations as get_annotations -elif sys.version_info >= (3, 10): +else: def get_annotations( obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module *, @@ -412,7 +406,7 @@ if sys.version_info >= (3, 12): AGEN_CLOSED: Final = "AGEN_CLOSED" def getasyncgenstate( - agen: AsyncGenerator[Any, Any], + agen: AsyncGenerator[Any, Any] ) -> Literal["AGEN_CREATED", "AGEN_RUNNING", "AGEN_SUSPENDED", "AGEN_CLOSED"]: ... def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ... @@ -677,7 +671,7 @@ GEN_SUSPENDED: Final = "GEN_SUSPENDED" GEN_CLOSED: Final = "GEN_CLOSED" def getgeneratorstate( - generator: Generator[Any, Any, Any], + generator: Generator[Any, Any, Any] ) -> Literal["GEN_CREATED", "GEN_RUNNING", "GEN_SUSPENDED", "GEN_CLOSED"]: ... CORO_CREATED: Final = "CORO_CREATED" @@ -686,7 +680,7 @@ CORO_SUSPENDED: Final = "CORO_SUSPENDED" CORO_CLOSED: Final = "CORO_CLOSED" def getcoroutinestate( - coroutine: Coroutine[Any, Any, Any], + coroutine: Coroutine[Any, Any, Any] ) -> Literal["CORO_CREATED", "CORO_RUNNING", "CORO_SUSPENDED", "CORO_CLOSED"]: ... def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> dict[str, Any]: ... def getcoroutinelocals(coroutine: Coroutine[Any, Any, Any]) -> dict[str, Any]: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index d09804cb9342..c115420ca142 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -18,7 +18,7 @@ def ip_network( address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], strict: bool = True ) -> IPv4Network | IPv6Network: ... def ip_interface( - address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], + address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int] ) -> IPv4Interface | IPv6Interface: ... class _IPAddressBase: diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 8a924ad8b1e7..9b3cf4327c44 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -332,12 +332,11 @@ class combinations_with_replacement(Generic[_T_co]): def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... -if sys.version_info >= (3, 10): - @disjoint_base - class pairwise(Generic[_T_co]): - def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... - def __iter__(self) -> Self: ... - def __next__(self) -> _T_co: ... +@disjoint_base +class pairwise(Generic[_T_co]): + def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... + def __iter__(self) -> Self: ... + def __next__(self) -> _T_co: ... if sys.version_info >= (3, 12): @disjoint_base diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 80c39a532dc8..44f9315678e0 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -153,10 +153,7 @@ if sys.version_info < (3, 12): def format_string(f: _str, val: Any, grouping: bool = False, monetary: bool = False) -> _str: ... def currency(val: float | Decimal, symbol: bool = True, grouping: bool = False, international: bool = False) -> _str: ... def delocalize(string: _str) -> _str: ... - -if sys.version_info >= (3, 10): - def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... - +def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 89c94816a906..bfe71cc72876 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -274,21 +274,15 @@ class Formatter: default_time_format: str default_msec_format: str | None - if sys.version_info >= (3, 10): - def __init__( - self, - fmt: str | None = None, - datefmt: str | None = None, - style: _FormatStyle = "%", - validate: bool = True, - *, - defaults: Mapping[str, Any] | None = None, - ) -> None: ... - else: - def __init__( - self, fmt: str | None = None, datefmt: str | None = None, style: _FormatStyle = "%", validate: bool = True - ) -> None: ... - + def __init__( + self, + fmt: str | None = None, + datefmt: str | None = None, + style: _FormatStyle = "%", + validate: bool = True, + *, + defaults: Mapping[str, Any] | None = None, + ) -> None: ... def format(self, record: LogRecord) -> str: ... def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str: ... def formatException(self, ei: _SysExcInfoType) -> str: ... @@ -362,18 +356,12 @@ _L = TypeVar("_L", bound=Logger | LoggerAdapter[Any]) class LoggerAdapter(Generic[_L]): logger: _L manager: Manager # undocumented + extra: Mapping[str, object] | None if sys.version_info >= (3, 13): def __init__(self, logger: _L, extra: Mapping[str, object] | None = None, merge_extra: bool = False) -> None: ... - elif sys.version_info >= (3, 10): - def __init__(self, logger: _L, extra: Mapping[str, object] | None = None) -> None: ... - else: - def __init__(self, logger: _L, extra: Mapping[str, object]) -> None: ... - - if sys.version_info >= (3, 10): - extra: Mapping[str, object] | None else: - extra: Mapping[str, object] + def __init__(self, logger: _L, extra: Mapping[str, object] | None = None) -> None: ... if sys.version_info >= (3, 13): merge_extra: bool @@ -663,11 +651,8 @@ class PercentStyle: # undocumented asctime_search: str validation_pattern: Pattern[str] _fmt: str - if sys.version_info >= (3, 10): - def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... - else: - def __init__(self, fmt: str) -> None: ... + def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... def usesTime(self) -> bool: ... def validate(self) -> None: ... def format(self, record: Any) -> str: ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index e36214551600..a9e8ee3674f8 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -64,22 +64,12 @@ class _DictConfigArgs(TypedDict, total=False): # Also accept a TypedDict type, to allow callers to use TypedDict # types, and for somewhat stricter type checking of dict literals. def dictConfig(config: _DictConfigArgs | dict[str, Any]) -> None: ... - -if sys.version_info >= (3, 10): - def fileConfig( - fname: StrOrBytesPath | IO[str] | RawConfigParser, - defaults: Mapping[str, str] | None = None, - disable_existing_loggers: bool = True, - encoding: str | None = None, - ) -> None: ... - -else: - def fileConfig( - fname: StrOrBytesPath | IO[str] | RawConfigParser, - defaults: Mapping[str, str] | None = None, - disable_existing_loggers: bool = True, - ) -> None: ... - +def fileConfig( + fname: StrOrBytesPath | IO[str] | RawConfigParser, + defaults: Mapping[str, str] | None = None, + disable_existing_loggers: bool = True, + encoding: str | None = None, +) -> None: ... def valid_ident(s: str) -> Literal[True]: ... # undocumented def listen(port: int = 9030, verify: Callable[[bytes], bytes | None] | None = None) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 12425f703aa1..a17cdcc48dd0 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -15,8 +15,7 @@ ALLOCATIONGRANULARITY: Final[int] if sys.platform == "linux": MAP_DENYWRITE: Final[int] MAP_EXECUTABLE: Final[int] - if sys.version_info >= (3, 10): - MAP_POPULATE: Final[int] + MAP_POPULATE: Final[int] if sys.version_info >= (3, 11) and sys.platform != "win32" and sys.platform != "darwin": MAP_STACK: Final[int] @@ -129,7 +128,7 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win MADV_CORE: Final[int] MADV_PROTECT: Final[int] -if sys.version_info >= (3, 10) and sys.platform == "darwin": +if sys.platform == "darwin": MADV_FREE_REUSABLE: Final[int] MADV_FREE_REUSE: Final[int] diff --git a/stdlib/msvcrt.pyi b/stdlib/msvcrt.pyi index 5feca8eab5c1..1518f7974de7 100644 --- a/stdlib/msvcrt.pyi +++ b/stdlib/msvcrt.pyi @@ -28,5 +28,4 @@ if sys.platform == "win32": def ungetwch(unicode_char: str, /) -> None: ... def heapmin() -> None: ... def SetErrorMode(mode: int, /) -> int: ... - if sys.version_info >= (3, 10): - def GetErrorMode() -> int: ... # undocumented + def GetErrorMode() -> int: ... # undocumented diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index bb169ed6b2ed..a293a3b9fb59 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -250,11 +250,7 @@ class Server: ) -> None: ... def serve_forever(self) -> None: ... def accepter(self) -> None: ... - if sys.version_info >= (3, 10): - def handle_request(self, conn: _ServerConnection) -> None: ... - else: - def handle_request(self, c: _ServerConnection) -> None: ... - + def handle_request(self, conn: _ServerConnection) -> None: ... def serve_client(self, conn: _ServerConnection) -> None: ... def fallback_getvalue(self, conn: _ServerConnection, ident: str, obj: _T) -> _T: ... def fallback_str(self, conn: _ServerConnection, ident: str, obj: Any) -> str: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 66a9d1dd3bc6..b792e4328a0e 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -178,7 +178,7 @@ if sys.version_info >= (3, 14): __all__ += ["readinto", "reload_environ"] if sys.platform == "darwin" and sys.version_info >= (3, 12): __all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"] -if sys.platform == "darwin" and sys.version_info >= (3, 10): +if sys.platform == "darwin": __all__ += ["O_EVTONLY", "O_NOFOLLOW_ANY", "O_SYMLINK"] if sys.platform == "linux": __all__ += [ @@ -259,7 +259,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 12): "unshare", "PIDFD_NONBLOCK", ] -if sys.platform == "linux" and sys.version_info >= (3, 10): +if sys.platform == "linux": __all__ += [ "EFD_CLOEXEC", "EFD_NONBLOCK", @@ -446,7 +446,7 @@ if sys.platform != "win32" and sys.version_info >= (3, 13): __all__ += ["grantpt", "posix_openpt", "ptsname", "unlockpt"] if sys.platform != "win32" and sys.version_info >= (3, 11): __all__ += ["login_tty"] -if sys.platform != "win32" and sys.version_info >= (3, 10): +if sys.platform != "win32": __all__ += ["O_FSYNC"] if sys.platform != "darwin" and sys.platform != "win32": __all__ += [ @@ -661,12 +661,12 @@ if sys.platform != "linux" and sys.platform != "win32": O_SHLOCK: Final[int] O_EXLOCK: Final[int] -if sys.platform == "darwin" and sys.version_info >= (3, 10): +if sys.platform == "darwin": O_EVTONLY: Final[int] O_NOFOLLOW_ANY: Final[int] O_SYMLINK: Final[int] -if sys.platform != "win32" and sys.version_info >= (3, 10): +if sys.platform != "win32": O_FSYNC: Final[int] if sys.platform != "linux" and sys.platform != "win32" and sys.version_info >= (3, 13): @@ -805,8 +805,7 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime. # # More items may be added at the end by some implementations. - if sys.version_info >= (3, 10): - __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") + __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") @property def st_mode(self) -> int: ... # protection bits, @@ -829,9 +828,11 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) if sys.version_info >= (3, 12) and sys.platform == "win32": @property - @deprecated("""\ + @deprecated( + """\ Use st_birthtime instead to retrieve the file creation time. \ -In the future, this property will contain the last metadata change time.""") +In the future, this property will contain the last metadata change time.""" + ) def st_ctime(self) -> float: ... else: @property @@ -911,19 +912,18 @@ class DirEntry(Generic[AnyStr]): @final class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "f_bsize", - "f_frsize", - "f_blocks", - "f_bfree", - "f_bavail", - "f_files", - "f_ffree", - "f_favail", - "f_flag", - "f_namemax", - ) + __match_args__: Final = ( + "f_bsize", + "f_frsize", + "f_blocks", + "f_bfree", + "f_bavail", + "f_files", + "f_ffree", + "f_favail", + "f_flag", + "f_namemax", + ) @property def f_bsize(self) -> int: ... @@ -965,8 +965,7 @@ def strerror(code: int, /) -> str: ... def umask(mask: int, /) -> int: ... @final class uname_result(structseq[str], tuple[str, str, str, str, str]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") + __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") @property def sysname(self) -> str: ... @@ -1154,8 +1153,7 @@ if sys.platform != "win32": def preadv(fd: int, buffers: SupportsLenAndGetItem[WriteableBuffer], offset: int, flags: int = 0, /) -> int: ... def pwritev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], offset: int, flags: int = 0, /) -> int: ... if sys.platform != "darwin": - if sys.version_info >= (3, 10): - RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise + RWF_APPEND: Final[int] RWF_DSYNC: Final[int] RWF_SYNC: Final[int] RWF_HIPRI: Final[int] @@ -1182,8 +1180,7 @@ if sys.version_info >= (3, 14): @final class terminal_size(structseq[int], tuple[int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("columns", "lines") + __match_args__: Final = ("columns", "lines") @property def columns(self) -> int: ... @@ -1452,8 +1449,7 @@ else: @final class times_result(structseq[float], tuple[float, float, float, float, float]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") + __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") @property def user(self) -> float: ... @@ -1470,16 +1466,9 @@ def times() -> times_result: ... def waitpid(pid: int, options: int, /) -> tuple[int, int]: ... if sys.platform == "win32": - if sys.version_info >= (3, 10): - def startfile( - filepath: StrOrBytesPath, - operation: str = ..., - arguments: str = "", - cwd: StrOrBytesPath | None = None, - show_cmd: int = 1, - ) -> None: ... - else: - def startfile(filepath: StrOrBytesPath, operation: str = ...) -> None: ... + def startfile( + filepath: StrOrBytesPath, operation: str = ..., arguments: str = "", cwd: StrOrBytesPath | None = None, show_cmd: int = 1 + ) -> None: ... else: if sys.version_info >= (3, 14): @@ -1503,8 +1492,7 @@ else: if sys.platform != "darwin" or sys.version_info >= (3, 13): @final class waitid_result(structseq[int], tuple[int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") + __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") @property def si_pid(self) -> int: ... @@ -1627,8 +1615,7 @@ else: if sys.platform != "win32": @final class sched_param(structseq[int], tuple[int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("sched_priority",) + __match_args__: Final = ("sched_priority",) def __new__(cls, sched_priority: int) -> Self: ... @property @@ -1719,7 +1706,7 @@ if sys.version_info >= (3, 12) and sys.platform == "win32": def listmounts(volume: str) -> list[str]: ... def listvolumes() -> list[str]: ... -if sys.version_info >= (3, 10) and sys.platform == "linux": +if sys.platform == "linux": EFD_CLOEXEC: Final[int] EFD_NONBLOCK: Final[int] EFD_SEMAPHORE: Final[int] diff --git a/stdlib/pathlib/__init__.pyi b/stdlib/pathlib/__init__.pyi index 4f094130665c..12cd36425d13 100644 --- a/stdlib/pathlib/__init__.pyi +++ b/stdlib/pathlib/__init__.pyi @@ -151,10 +151,8 @@ class PureWindowsPath(PurePath): class Path(PurePath): if sys.version_info >= (3, 14): __slots__ = ("_info",) - elif sys.version_info >= (3, 10): - __slots__ = () else: - __slots__ = ("_accessor",) + __slots__ = () if sys.version_info >= (3, 12): def __new__(cls, *args: StrPath, **kwargs: Unused) -> Self: ... # pyright: ignore[reportInconsistentConstructor] @@ -163,12 +161,8 @@ class Path(PurePath): @classmethod def cwd(cls) -> Self: ... - if sys.version_info >= (3, 10): - def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... - def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... - else: - def stat(self) -> stat_result: ... - def chmod(self, mode: int) -> None: ... + def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... + def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... if sys.version_info >= (3, 13): @classmethod @@ -314,20 +308,12 @@ class Path(PurePath): def is_mount(self) -> bool: ... def readlink(self) -> Self: ... - - if sys.version_info >= (3, 10): - def rename(self, target: StrPath) -> Self: ... - def replace(self, target: StrPath) -> Self: ... - else: - def rename(self, target: str | PurePath) -> Self: ... - def replace(self, target: str | PurePath) -> Self: ... - + def rename(self, target: StrPath) -> Self: ... + def replace(self, target: StrPath) -> Self: ... def resolve(self, strict: bool = False) -> Self: ... def rmdir(self) -> None: ... def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ... - if sys.version_info >= (3, 10): - def hardlink_to(self, target: StrOrBytesPath) -> None: ... - + def hardlink_to(self, target: StrOrBytesPath) -> None: ... def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: ... def unlink(self, missing_ok: bool = False) -> None: ... @classmethod @@ -337,18 +323,12 @@ class Path(PurePath): def read_bytes(self) -> bytes: ... def samefile(self, other_path: StrPath) -> bool: ... def write_bytes(self, data: ReadableBuffer) -> int: ... - if sys.version_info >= (3, 10): - def write_text( - self, data: str, encoding: str | None = None, errors: str | None = None, newline: str | None = None - ) -> int: ... - else: - def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ... + def write_text( + self, data: str, encoding: str | None = None, errors: str | None = None, newline: 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.") - def link_to(self, target: StrOrBytesPath) -> None: ... - else: - def link_to(self, target: StrOrBytesPath) -> None: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") + def link_to(self, target: StrOrBytesPath) -> None: ... if sys.version_info >= (3, 12): def walk( self, top_down: bool = True, on_error: Callable[[OSError], object] | None = None, follow_symlinks: bool = False diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index 4952f7782358..1b01e3144e63 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -4,7 +4,6 @@ from _typeshed import ReadableBuffer from bdb import Bdb, _Backend from cmd import Cmd from collections.abc import Callable, Iterable, Mapping, Sequence -from inspect import _SourceObjectType from linecache import _ModuleGlobals from rlcompleter import Completer from types import CodeType, FrameType, TracebackType @@ -266,10 +265,6 @@ class Pdb(Bdb, Cmd): def find_function(funcname: str, filename: str) -> tuple[str, str, int] | None: ... def main() -> None: ... def help() -> None: ... - -if sys.version_info < (3, 10): - def getsourcelines(obj: _SourceObjectType) -> tuple[list[str], int]: ... - def lasti2lineno(code: CodeType, lasti: int) -> int: ... class _rstr(str): diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 69d702bb155c..a9c4eac04f82 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -57,9 +57,7 @@ if sys.version_info >= (3, 12): else: @disjoint_base class uname_result(_uname_result_base): - if sys.version_info >= (3, 10): - __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] - + __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] def __new__(_cls, system: str, node: str, release: str, version: str, machine: str) -> Self: ... @property def processor(self) -> str: ... @@ -79,9 +77,7 @@ def python_revision() -> str: ... def python_build() -> tuple[str, str]: ... def python_compiler() -> str: ... def platform(aliased: bool = False, terse: bool = False) -> str: ... - -if sys.version_info >= (3, 10): - def freedesktop_os_release() -> dict[str, str]: ... +def freedesktop_os_release() -> dict[str, str]: ... if sys.version_info >= (3, 13): class AndroidVer(NamedTuple): diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 6d0d76ab8217..f3e96f0c095c 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -39,6 +39,7 @@ if sys.platform != "win32": O_DIRECTORY as O_DIRECTORY, O_DSYNC as O_DSYNC, O_EXCL as O_EXCL, + O_FSYNC as O_FSYNC, O_NDELAY as O_NDELAY, O_NOCTTY as O_NOCTTY, O_NOFOLLOW as O_NOFOLLOW, @@ -227,9 +228,6 @@ if sys.platform != "win32": writev as writev, ) - if sys.version_info >= (3, 10): - from os import O_FSYNC as O_FSYNC - if sys.version_info >= (3, 11): from os import login_tty as login_tty @@ -273,6 +271,7 @@ if sys.platform != "win32": POSIX_FADV_RANDOM as POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL as POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED as POSIX_FADV_WILLNEED, + RWF_APPEND as RWF_APPEND, RWF_DSYNC as RWF_DSYNC, RWF_HIPRI as RWF_HIPRI, RWF_NOWAIT as RWF_NOWAIT, @@ -303,14 +302,14 @@ if sys.platform != "win32": setresuid as setresuid, ) - if sys.version_info >= (3, 10): - from os import RWF_APPEND as RWF_APPEND - if sys.platform != "darwin" or sys.version_info >= (3, 13): from os import waitid as waitid, waitid_result as waitid_result if sys.platform == "linux": from os import ( + EFD_CLOEXEC as EFD_CLOEXEC, + EFD_NONBLOCK as EFD_NONBLOCK, + EFD_SEMAPHORE as EFD_SEMAPHORE, GRND_NONBLOCK as GRND_NONBLOCK, GRND_RANDOM as GRND_RANDOM, MFD_ALLOW_SEALING as MFD_ALLOW_SEALING, @@ -341,10 +340,16 @@ if sys.platform != "win32": SCHED_BATCH as SCHED_BATCH, SCHED_IDLE as SCHED_IDLE, SCHED_RESET_ON_FORK as SCHED_RESET_ON_FORK, + SPLICE_F_MORE as SPLICE_F_MORE, + SPLICE_F_MOVE as SPLICE_F_MOVE, + SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, XATTR_CREATE as XATTR_CREATE, XATTR_REPLACE as XATTR_REPLACE, XATTR_SIZE_MAX as XATTR_SIZE_MAX, copy_file_range as copy_file_range, + eventfd as eventfd, + eventfd_read as eventfd_read, + eventfd_write as eventfd_write, getrandom as getrandom, getxattr as getxattr, listxattr as listxattr, @@ -352,22 +357,9 @@ if sys.platform != "win32": pidfd_open as pidfd_open, removexattr as removexattr, setxattr as setxattr, + splice as splice, ) - if sys.version_info >= (3, 10): - from os import ( - EFD_CLOEXEC as EFD_CLOEXEC, - EFD_NONBLOCK as EFD_NONBLOCK, - EFD_SEMAPHORE as EFD_SEMAPHORE, - SPLICE_F_MORE as SPLICE_F_MORE, - SPLICE_F_MOVE as SPLICE_F_MOVE, - SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, - eventfd as eventfd, - eventfd_read as eventfd_read, - eventfd_write as eventfd_write, - splice as splice, - ) - if sys.version_info >= (3, 12): from os import ( CLONE_FILES as CLONE_FILES, @@ -390,6 +382,8 @@ if sys.platform != "win32": ) if sys.platform == "darwin": + from os import O_EVTONLY as O_EVTONLY, O_NOFOLLOW_ANY as O_NOFOLLOW_ANY, O_SYMLINK as O_SYMLINK + if sys.version_info >= (3, 12): from os import ( PRIO_DARWIN_BG as PRIO_DARWIN_BG, @@ -397,8 +391,6 @@ if sys.platform != "win32": PRIO_DARWIN_PROCESS as PRIO_DARWIN_PROCESS, PRIO_DARWIN_THREAD as PRIO_DARWIN_THREAD, ) - if sys.platform == "darwin" and sys.version_info >= (3, 10): - from os import O_EVTONLY as O_EVTONLY, O_NOFOLLOW_ANY as O_NOFOLLOW_ANY, O_SYMLINK as O_SYMLINK # Not same as os.environ or os.environb # Because of this variable, we can't do "from posix import *" in os/__init__.pyi diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index 1e80462e2565..4085731a2a05 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -1,112 +1,57 @@ -import sys from _typeshed import SupportsWrite from collections import deque from typing import IO __all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"] -if sys.version_info >= (3, 10): - def pformat( - object: object, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, - ) -> str: ... - -else: - def pformat( - object: object, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> str: ... - -if sys.version_info >= (3, 10): - def pp( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = False, - underscore_numbers: bool = False, - ) -> None: ... +def pformat( + object: object, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, +) -> str: ... +def pp( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = False, + underscore_numbers: bool = False, +) -> None: ... +def pprint( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, +) -> None: ... +def isreadable(object: object) -> bool: ... +def isrecursive(object: object) -> bool: ... +def saferepr(object: object) -> str: ... -else: - def pp( - object: object, - stream: IO[str] | None = None, +class PrettyPrinter: + def __init__( + self, indent: int = 1, width: int = 80, depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = False, - ) -> None: ... - -if sys.version_info >= (3, 10): - def pprint( - object: object, stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, *, compact: bool = False, sort_dicts: bool = True, underscore_numbers: bool = False, ) -> None: ... - -else: - def pprint( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> None: ... - -def isreadable(object: object) -> bool: ... -def isrecursive(object: object) -> bool: ... -def saferepr(object: object) -> str: ... - -class PrettyPrinter: - if sys.version_info >= (3, 10): - def __init__( - self, - indent: int = 1, - width: int = 80, - depth: int | None = None, - stream: IO[str] | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, - ) -> None: ... - else: - def __init__( - self, - indent: int = 1, - width: int = 80, - depth: int | None = None, - stream: IO[str] | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> None: ... - def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... @@ -155,5 +100,4 @@ class PrettyPrinter: self, items: list[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int ) -> None: ... def _repr(self, object: object, context: dict[int, int], level: int) -> str: ... - if sys.version_info >= (3, 10): - def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... + def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index a84ba324718a..6a7e24f78125 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -5,8 +5,7 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") + __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") @property def pw_name(self) -> str: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 334ce79b5dd0..e0ee67c5e93f 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,5 +1,4 @@ import enum -import sys from typing import AnyStr __all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] @@ -26,9 +25,4 @@ def compile( invalidation_mode: PycInvalidationMode | None = None, quiet: int = 0, ) -> AnyStr | None: ... - -if sys.version_info >= (3, 10): - def main() -> None: ... - -else: - def main(args: list[str] | None = None) -> int: ... +def main() -> None: ... diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 504a5d5f115a..541f962d33e1 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping, Sequence __all__ = ["readmodule", "readmodule_ex", "Class", "Function"] @@ -8,44 +7,33 @@ class _Object: name: str file: int lineno: int - - if sys.version_info >= (3, 10): - end_lineno: int | None - + end_lineno: int | None parent: _Object | None # This is a dict at runtime, but we're typing it as Mapping to # avoid variance issues in the subclasses children: Mapping[str, _Object] - if sys.version_info >= (3, 10): - def __init__( - self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None - ) -> None: ... - else: - def __init__(self, module: str, name: str, file: str, lineno: int, parent: _Object | None) -> None: ... + def __init__( + self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None + ) -> None: ... class Function(_Object): - if sys.version_info >= (3, 10): - is_async: bool - + is_async: bool parent: Function | Class | None children: dict[str, Class | Function] - if sys.version_info >= (3, 10): - def __init__( - self, - module: str, - name: str, - file: str, - lineno: int, - parent: Function | Class | None = None, - is_async: bool = False, - *, - end_lineno: int | None = None, - ) -> None: ... - else: - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | Class | None = None) -> None: ... + def __init__( + self, + module: str, + name: str, + file: str, + lineno: int, + parent: Function | Class | None = None, + is_async: bool = False, + *, + end_lineno: int | None = None, + ) -> None: ... class Class(_Object): super: list[Class | str] | None @@ -53,22 +41,17 @@ class Class(_Object): parent: Class | None children: dict[str, Class | Function] - if sys.version_info >= (3, 10): - def __init__( - self, - module: str, - name: str, - super_: list[Class | str] | None, - file: str, - lineno: int, - parent: Class | None = None, - *, - end_lineno: int | None = None, - ) -> None: ... - else: - def __init__( - self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int, parent: Class | None = None - ) -> None: ... + def __init__( + self, + module: str, + name: str, + super_: list[Class | str] | None, + file: str, + lineno: int, + parent: Class | None = None, + *, + end_lineno: int | None = None, + ) -> None: ... def readmodule(module: str, path: Sequence[str] | None = None) -> dict[str, Class]: ... def readmodule_ex(module: str, path: Sequence[str] | None = None) -> dict[str, Class | Function | list[str]]: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index bc522d5f3c92..c41e5177f416 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import ReadableBuffer, SupportsRead from collections.abc import Callable from pyexpat import errors as errors, model as model @@ -30,11 +29,9 @@ class XMLParserType: def UseForeignDTD(self, flag: bool = True, /) -> None: ... def GetReparseDeferralEnabled(self) -> bool: ... def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ... - if sys.version_info >= (3, 10): - # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 - def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... - def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... - + # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 + def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... + def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... @property def intern(self) -> dict[str, str]: ... buffer_size: int diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 08619bf66351..e7911ceeab18 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -4,7 +4,7 @@ from _typeshed import SupportsLenAndGetItem from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet from fractions import Fraction from typing import Any, ClassVar, NoReturn, TypeVar, overload -from typing_extensions import Self, deprecated +from typing_extensions import deprecated __all__ = [ "Random", @@ -45,9 +45,6 @@ class Random(_random.Random): # Using other `seed` types is deprecated since 3.9 and removed in 3.11 # Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit # int better documents conventional usage of random.seed. - if sys.version_info < (3, 10): - # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 - def __new__(cls, x: int | float | str | bytes | bytearray | None = None) -> Self: ... # noqa: Y041 def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041 def getstate(self) -> tuple[Any, ...]: ... diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index f99cd5b08805..6cd5db48a8c2 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -30,25 +30,24 @@ if sys.platform != "win32": class struct_rusage( structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] ): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "ru_utime", - "ru_stime", - "ru_maxrss", - "ru_ixrss", - "ru_idrss", - "ru_isrss", - "ru_minflt", - "ru_majflt", - "ru_nswap", - "ru_inblock", - "ru_oublock", - "ru_msgsnd", - "ru_msgrcv", - "ru_nsignals", - "ru_nvcsw", - "ru_nivcsw", - ) + __match_args__: Final = ( + "ru_utime", + "ru_stime", + "ru_maxrss", + "ru_ixrss", + "ru_idrss", + "ru_isrss", + "ru_minflt", + "ru_majflt", + "ru_nswap", + "ru_inblock", + "ru_oublock", + "ru_msgsnd", + "ru_msgrcv", + "ru_nsignals", + "ru_nvcsw", + "ru_nivcsw", + ) @property def ru_utime(self) -> float: ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 436d9984ee4d..5d215b5372e4 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,33 +1,19 @@ -import sys import time from collections.abc import Callable -from typing import Any, ClassVar, NamedTuple, type_check_only +from typing import Any, NamedTuple from typing_extensions import TypeAlias __all__ = ["scheduler"] _ActionCallback: TypeAlias = Callable[..., Any] -if sys.version_info >= (3, 10): - class Event(NamedTuple): - time: float - priority: Any - sequence: int - action: _ActionCallback - argument: tuple[Any, ...] - kwargs: dict[str, Any] - -else: - @type_check_only - class _EventBase(NamedTuple): - time: float - priority: Any - action: _ActionCallback - argument: tuple[Any, ...] - kwargs: dict[str, Any] - - class Event(_EventBase): - __hash__: ClassVar[None] # type: ignore[assignment] +class Event(NamedTuple): + time: float + priority: Any + sequence: int + action: _ActionCallback + argument: tuple[Any, ...] + kwargs: dict[str, Any] class scheduler: timefunc: Callable[[], float] diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 3bf1d3129378..4dc5a000b705 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -69,14 +69,8 @@ _SIGNUM: TypeAlias = int | Signals _HANDLER: TypeAlias = Callable[[int, FrameType | None], Any] | int | Handlers | None def default_int_handler(signalnum: int, frame: FrameType | None, /) -> Never: ... - -if sys.version_info >= (3, 10): # arguments changed in 3.10.2 - def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... - def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... - -else: - def getsignal(signalnum: _SIGNUM, /) -> _HANDLER: ... - def signal(signalnum: _SIGNUM, handler: _HANDLER, /) -> _HANDLER: ... +def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... +def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... SIGABRT: Final = Signals.SIGABRT SIGFPE: Final = Signals.SIGFPE @@ -135,18 +129,11 @@ else: def getitimer(which: int, /) -> tuple[float, float]: ... def pause() -> None: ... def pthread_kill(thread_id: int, signalnum: int, /) -> None: ... - if sys.version_info >= (3, 10): # arguments changed in 3.10.2 - def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... - else: - def pthread_sigmask(how: int, mask: Iterable[int], /) -> set[_SIGNUM]: ... - + def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... def setitimer(which: int, seconds: float, interval: float = 0.0, /) -> tuple[float, float]: ... def siginterrupt(signalnum: int, flag: bool, /) -> None: ... def sigpending() -> Any: ... - if sys.version_info >= (3, 10): # argument changed in 3.10.2 - def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... - else: - def sigwait(sigset: Iterable[int], /) -> _SIGNUM: ... + def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... if sys.platform != "darwin": SIGCLD: Final = Signals.SIGCHLD # alias SIGPOLL: Final = Signals.SIGIO # alias @@ -158,8 +145,7 @@ else: @final class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") + __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") @property def si_signo(self) -> int: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index a55273a8772c..bc3327d6a0ad 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -28,6 +28,7 @@ from _socket import ( IP_MULTICAST_LOOP as IP_MULTICAST_LOOP, IP_MULTICAST_TTL as IP_MULTICAST_TTL, IP_OPTIONS as IP_OPTIONS, + IP_RECVTOS as IP_RECVTOS, IP_TOS as IP_TOS, IP_TTL as IP_TTL, IPPORT_RESERVED as IPPORT_RESERVED, @@ -223,6 +224,7 @@ __all__ = [ "IP_MULTICAST_LOOP", "IP_MULTICAST_TTL", "IP_OPTIONS", + "IP_RECVTOS", "IP_TOS", "IP_TTL", "MSG_CTRUNC", @@ -357,11 +359,6 @@ if sys.platform != "darwin": __all__ += ["TCP_KEEPIDLE", "AF_IRDA", "MSG_ERRQUEUE"] -if sys.version_info >= (3, 10): - from _socket import IP_RECVTOS as IP_RECVTOS - - __all__ += ["IP_RECVTOS"] - if sys.platform != "win32" and sys.platform != "darwin": from _socket import ( IP_TRANSPARENT as IP_TRANSPARENT, @@ -525,7 +522,7 @@ if sys.platform != "darwin": if sys.platform != "darwin" and sys.platform != "linux": __all__ += ["BDADDR_ANY", "BDADDR_LOCAL", "BTPROTO_RFCOMM"] -if sys.platform == "darwin" and sys.version_info >= (3, 10): +if sys.platform == "darwin": from _socket import TCP_KEEPALIVE as TCP_KEEPALIVE __all__ += ["TCP_KEEPALIVE"] @@ -842,7 +839,7 @@ if sys.platform == "linux": "UDPLITE_RECV_CSCOV", "UDPLITE_SEND_CSCOV", ] -if sys.platform == "linux" and sys.version_info >= (3, 10): +if sys.platform == "linux": from _socket import IPPROTO_MPTCP as IPPROTO_MPTCP __all__ += ["IPPROTO_MPTCP"] @@ -1087,10 +1084,7 @@ error = OSError class herror(error): ... class gaierror(error): ... -if sys.version_info >= (3, 10): - timeout = TimeoutError -else: - class timeout(error): ... +timeout = TimeoutError class AddressFamily(IntEnum): AF_INET = 2 diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index 3a5d39997dcc..0a06cdfeef64 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -5,18 +5,17 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_spwd(structseq[Any], tuple[str, str, int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "sp_namp", - "sp_pwdp", - "sp_lstchg", - "sp_min", - "sp_max", - "sp_warn", - "sp_inact", - "sp_expire", - "sp_flag", - ) + __match_args__: Final = ( + "sp_namp", + "sp_pwdp", + "sp_lstchg", + "sp_min", + "sp_max", + "sp_warn", + "sp_inact", + "sp_expire", + "sp_flag", + ) @property def sp_namp(self) -> str: ... diff --git a/stdlib/sqlite3/__init__.pyi b/stdlib/sqlite3/__init__.pyi index 86ae7bccdb11..4abb05236e31 100644 --- a/stdlib/sqlite3/__init__.pyi +++ b/stdlib/sqlite3/__init__.pyi @@ -211,9 +211,6 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): from sqlite3.dbapi2 import enable_shared_cache as enable_shared_cache, version as version -if sys.version_info < (3, 10): - from sqlite3.dbapi2 import OptimizedUnicode as OptimizedUnicode - _CursorT = TypeVar("_CursorT", bound=Cursor) _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None # Data that is passed through adapters can be of any type accepted by an adapter. diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 9e170a81243d..dc5bf11f15ee 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -215,18 +215,12 @@ if sys.version_info < (3, 14): version: Final[str] if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - # deprecation wrapper that has a different name for the argument... - @deprecated( - "Deprecated since Python 3.10; removed in Python 3.12. " - "Open database in URI mode using `cache=shared` parameter instead." - ) - def enable_shared_cache(enable: int) -> None: ... - else: - from _sqlite3 import enable_shared_cache as enable_shared_cache - -if sys.version_info < (3, 10): - from _sqlite3 import OptimizedUnicode as OptimizedUnicode + # deprecation wrapper that has a different name for the argument... + @deprecated( + "Deprecated since Python 3.10; removed in Python 3.12. " + "Open database in URI mode using `cache=shared` parameter instead." + ) + def enable_shared_cache(enable: int) -> None: ... paramstyle: Final = "qmark" threadsafety: Literal[0, 1, 3] diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 57952cf19bbe..a482b208eba8 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -39,9 +39,6 @@ if sys.version_info >= (3, 14): if sys.version_info < (3, 12): from _ssl import RAND_pseudo_bytes as RAND_pseudo_bytes -if sys.version_info < (3, 10): - from _ssl import RAND_egd as RAND_egd - if sys.platform == "win32": from _ssl import enum_certificates as enum_certificates, enum_crls as enum_crls @@ -108,19 +105,16 @@ class VerifyFlags(enum.IntFlag): VERIFY_CRL_CHECK_CHAIN = 0x0C VERIFY_X509_STRICT = 0x20 VERIFY_X509_TRUSTED_FIRST = 0x8000 - if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS = 0x40 - VERIFY_X509_PARTIAL_CHAIN = 0x80000 + VERIFY_ALLOW_PROXY_CERTS = 0x40 + VERIFY_X509_PARTIAL_CHAIN = 0x80000 VERIFY_DEFAULT: Final = VerifyFlags.VERIFY_DEFAULT VERIFY_CRL_CHECK_LEAF: Final = VerifyFlags.VERIFY_CRL_CHECK_LEAF VERIFY_CRL_CHECK_CHAIN: Final = VerifyFlags.VERIFY_CRL_CHECK_CHAIN VERIFY_X509_STRICT: Final = VerifyFlags.VERIFY_X509_STRICT VERIFY_X509_TRUSTED_FIRST: Final = VerifyFlags.VERIFY_X509_TRUSTED_FIRST - -if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS - VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN +VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS +VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN class _SSLMethod(enum.IntEnum): PROTOCOL_SSLv23 = 2 @@ -307,12 +301,8 @@ class SSLSocket(socket.socket): def compression(self) -> str | None: ... def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def selected_alpn_protocol(self) -> str | None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... - else: - def selected_npn_protocol(self) -> str | None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ... def unwrap(self) -> socket.socket: ... def version(self) -> str | None: ... @@ -346,19 +336,9 @@ if sys.version_info < (3, 12): def cert_time_to_seconds(cert_time: str) -> int: ... def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... - -if sys.version_info >= (3, 10): - def get_server_certificate( - addr: tuple[str, int], - ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, - ca_certs: str | None = None, - timeout: float = ..., - ) -> str: ... - -else: - def get_server_certificate( - addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None - ) -> str: ... +def get_server_certificate( + addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None, timeout: float = ... +) -> str: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED = -2 @@ -385,17 +365,12 @@ class SSLContext(_SSLContext): sslsocket_class: type[SSLSocket] keylog_filename: str post_handshake_auth: bool - if sys.version_info >= (3, 10): - security_level: int - if sys.version_info >= (3, 10): - @overload - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... - @overload - @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") - def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... - else: - def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ... - + security_level: int + @overload + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... + @overload + @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") + def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... def load_default_certs(self, purpose: Purpose = Purpose.SERVER_AUTH) -> None: ... def load_verify_locations( self, @@ -413,12 +388,8 @@ class SSLContext(_SSLContext): def set_default_verify_paths(self) -> None: ... def set_ciphers(self, cipherlist: str, /) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - else: - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... def load_dh_params(self, path: str, /) -> None: ... def set_ecdh_curve(self, name: str, /) -> None: ... @@ -447,34 +418,18 @@ def create_default_context( capath: StrOrBytesPath | None = None, cadata: str | ReadableBuffer | None = None, ) -> SSLContext: ... - -if sys.version_info >= (3, 10): - def _create_unverified_context( - protocol: int | None = None, - *, - cert_reqs: int = VerifyMode.CERT_NONE, - check_hostname: bool = False, - purpose: Purpose = Purpose.SERVER_AUTH, - certfile: StrOrBytesPath | None = None, - keyfile: StrOrBytesPath | None = None, - cafile: StrOrBytesPath | None = None, - capath: StrOrBytesPath | None = None, - cadata: str | ReadableBuffer | None = None, - ) -> SSLContext: ... - -else: - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int = VerifyMode.CERT_NONE, - check_hostname: bool = False, - purpose: Purpose = Purpose.SERVER_AUTH, - certfile: StrOrBytesPath | None = None, - keyfile: StrOrBytesPath | None = None, - cafile: StrOrBytesPath | None = None, - capath: StrOrBytesPath | None = None, - cadata: str | ReadableBuffer | None = None, - ) -> SSLContext: ... +def _create_unverified_context( + protocol: int | None = None, + *, + cert_reqs: int = VerifyMode.CERT_NONE, + check_hostname: bool = False, + purpose: Purpose = Purpose.SERVER_AUTH, + certfile: StrOrBytesPath | None = None, + keyfile: StrOrBytesPath | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadata: str | ReadableBuffer | None = None, +) -> SSLContext: ... _create_default_https_context = create_default_context @@ -497,12 +452,8 @@ class SSLObject: @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def selected_alpn_protocol(self) -> str | None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... - else: - def selected_npn_protocol(self) -> str | None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... def cipher(self) -> tuple[str, str, int] | None: ... def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ... def compression(self) -> str | None: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index d9f282b99b66..6241b89857c2 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -8,8 +8,11 @@ from typing_extensions import Self, TypeAlias __all__ = [ "StatisticsError", + "covariance", + "correlation", "fmean", "geometric_mean", + "linear_regression", "mean", "harmonic_mean", "pstdev", @@ -26,8 +29,6 @@ __all__ = [ "quantiles", ] -if sys.version_info >= (3, 10): - __all__ += ["covariance", "correlation", "linear_regression"] if sys.version_info >= (3, 13): __all__ += ["kde", "kde_random"] @@ -57,13 +58,7 @@ else: def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... def mean(data: Iterable[_NumberT]) -> _NumberT: ... - -if sys.version_info >= (3, 10): - def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... - -else: - def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ... - +def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... def median(data: Iterable[_NumberT]) -> _NumberT: ... def median_low(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... def median_high(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... @@ -123,22 +118,21 @@ if sys.version_info >= (3, 12): x: Sequence[_Number], y: Sequence[_Number], /, *, method: Literal["linear", "ranked"] = "linear" ) -> float: ... -elif sys.version_info >= (3, 10): +else: def correlation(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... -if sys.version_info >= (3, 10): - def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... +def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... - class LinearRegression(NamedTuple): - slope: float - intercept: float +class LinearRegression(NamedTuple): + slope: float + intercept: float if sys.version_info >= (3, 11): def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], /, *, proportional: bool = False ) -> LinearRegression: ... -elif sys.version_info >= (3, 10): +else: def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], / ) -> LinearRegression: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 189da8d3aab6..31fec038d849 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -294,7 +294,7 @@ if sys.version_info >= (3, 11): process_group: int | None = None, ) -> CompletedProcess[Any]: ... -elif sys.version_info >= (3, 10): +else: # 3.10 adds "pipesize" argument @overload # text is True def run( @@ -496,457 +496,15 @@ elif sys.version_info >= (3, 10): pipesize: int = -1, ) -> CompletedProcess[Any]: ... -else: - @overload # text is True - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[True] | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: str | None = None, - text: Literal[True], - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload # encoding is str - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str, - errors: str | None = None, - input: str | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload # errors is str - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str, - input: str | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload # universal_newlines is True - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - *, - universal_newlines: Literal[True], - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - # where the *real* keyword only args start - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: str | None = None, - text: Literal[True] | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload # universal_newlines and text are False, None, or missing - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: None = None, - errors: None = None, - input: ReadableBuffer | None = None, - text: Literal[False] | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[bytes]: ... - @overload # fallback - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: _InputString | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[Any]: ... - # Same args as Popen.__init__ if sys.version_info >= (3, 11): # 3.11 adds "process_group" argument - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> int: ... - -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> int: ... - -else: - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> int: ... - -# Same args as Popen.__init__ -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> int: ... - -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> int: ... - -else: - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> int: ... - -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - @overload # text is True - def check_output( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[True] | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - timeout: float | None = None, - input: _InputString | None = None, - encoding: str | None = None, - errors: str | None = None, - text: Literal[True], - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload # encoding is str - def check_output( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - timeout: float | None = None, - input: _InputString | None = None, - encoding: str, - errors: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload # errors is str - def check_output( + def call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -960,10 +518,8 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, - input: _InputString | None = None, encoding: str | None = None, - errors: str, + timeout: float | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, @@ -971,76 +527,80 @@ if sys.version_info >= (3, 11): umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> str: ... - @overload # universal_newlines is True - def check_output( + ) -> int: ... + +else: + # 3.10 adds "pipesize" argument + def call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - *, - universal_newlines: Literal[True], + universal_newlines: bool | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - # where the real keyword only ones start - timeout: float | None = None, - input: _InputString | None = None, + *, encoding: str | None = None, - errors: str | None = None, - text: Literal[True] | None = None, + timeout: float | None = None, + text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload # universal_newlines and text are False, None, or missing - def check_output( + ) -> int: ... + +# Same args as Popen.__init__ +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument + def check_call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, + universal_newlines: bool | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - *, timeout: float | None = None, - input: _InputString | None = None, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, + *, + encoding: str | None = None, + text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> bytes: ... - @overload # fallback - def check_output( + ) -> int: ... + +else: + # 3.10 adds "pipesize" argument + def check_call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -1053,22 +613,19 @@ if sys.version_info >= (3, 11): restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - *, timeout: float | None = None, - input: _InputString | None = None, + *, encoding: str | None = None, - errors: str | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, - ) -> Any: ... # morally: -> str | bytes + ) -> int: ... -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument @overload # text is True def check_output( args: _CMD, @@ -1098,6 +655,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload # encoding is str def check_output( @@ -1128,6 +686,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload # errors is str def check_output( @@ -1158,6 +717,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload # universal_newlines is True def check_output( @@ -1189,6 +749,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload # universal_newlines and text are False, None, or missing def check_output( @@ -1219,6 +780,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> bytes: ... @overload # fallback def check_output( @@ -1249,9 +811,11 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> Any: ... # morally: -> str | bytes else: + # 3.10 adds "pipesize" argument @overload # text is True def check_output( args: _CMD, @@ -1280,6 +844,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload # encoding is str def check_output( @@ -1309,6 +874,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload # errors is str def check_output( @@ -1338,6 +904,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload # universal_newlines is True def check_output( @@ -1368,6 +935,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload # universal_newlines and text are False, None, or missing def check_output( @@ -1397,6 +965,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> bytes: ... @overload # fallback def check_output( @@ -1426,6 +995,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> Any: ... # morally: -> str | bytes PIPE: Final[int] @@ -1658,7 +1228,7 @@ class Popen(Generic[AnyStr]): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): + else: # pipesize is added in 3.10 @overload # encoding is str def __init__( @@ -1841,182 +1411,6 @@ class Popen(Generic[AnyStr]): umask: int = -1, pipesize: int = -1, ) -> None: ... - else: - @overload # encoding is str - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload # errors is str - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload # universal_newlines is True - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - *, - universal_newlines: Literal[True], - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - # where the *real* keyword only args start - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload # text is True - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[True] | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: Literal[True], - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload # universal_newlines and text are False, None, or missing - def __init__( - self: Popen[bytes], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: Literal[False] | None = None, - encoding: None = None, - errors: None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload # fallback - def __init__( - self: Popen[Any], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... def poll(self) -> int | None: ... def wait(self, timeout: float | None = None) -> int: ... diff --git a/stdlib/sys/__init__.pyi b/stdlib/sys/__init__.pyi index a3aa366f0c7e..b5627b36ee20 100644 --- a/stdlib/sys/__init__.pyi +++ b/stdlib/sys/__init__.pyi @@ -40,8 +40,7 @@ maxsize: int maxunicode: int meta_path: list[MetaPathFinderProtocol] modules: dict[str, ModuleType] -if sys.version_info >= (3, 10): - orig_argv: list[str] +orig_argv: list[str] path: list[str] path_hooks: list[Callable[[str], PathEntryFinderProtocol]] path_importer_cache: dict[str, PathEntryFinderProtocol | None] @@ -65,9 +64,7 @@ ps2: object stdin: TextIO | MaybeNone stdout: TextIO | MaybeNone stderr: TextIO | MaybeNone - -if sys.version_info >= (3, 10): - stdlib_module_names: frozenset[str] +stdlib_module_names: frozenset[str] __stdin__: Final[TextIOWrapper | None] # Contains the original value of stdin __stdout__: Final[TextIOWrapper | None] # Contains the original value of stdout @@ -124,7 +121,7 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): "safe_path", "int_max_str_digits", ) - elif sys.version_info >= (3, 10): + else: __match_args__: Final = ( "debug", "inspect", @@ -175,9 +172,8 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): def dev_mode(self) -> bool: ... @property def utf8_mode(self) -> int: ... - if sys.version_info >= (3, 10): - @property - def warn_default_encoding(self) -> int: ... + @property + def warn_default_encoding(self) -> int: ... if sys.version_info >= (3, 11): @property def safe_path(self) -> bool: ... @@ -203,20 +199,19 @@ float_info: _float_info @final @type_check_only class _float_info(structseq[float], tuple[float, int, int, float, int, int, int, int, float, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "max", - "max_exp", - "max_10_exp", - "min", - "min_exp", - "min_10_exp", - "dig", - "mant_dig", - "epsilon", - "radix", - "rounds", - ) + __match_args__: Final = ( + "max", + "max_exp", + "max_10_exp", + "min", + "min_exp", + "min_10_exp", + "dig", + "mant_dig", + "epsilon", + "radix", + "rounds", + ) @property def max(self) -> float: ... # DBL_MAX @@ -247,8 +242,7 @@ hash_info: _hash_info @final @type_check_only class _hash_info(structseq[Any | int], tuple[int, int, int, int, int, str, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") + __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") @property def width(self) -> int: ... @@ -290,8 +284,7 @@ int_info: _int_info @final @type_check_only class _int_info(structseq[int], tuple[int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") + __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") @property def bits_per_digit(self) -> int: ... @@ -309,8 +302,7 @@ _ThreadInfoLock: TypeAlias = Literal["semaphore", "mutex+cond"] | None @final @type_check_only class _thread_info(_UninstantiableStructseq, tuple[_ThreadInfoName, _ThreadInfoLock, str | None]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("name", "lock", "version") + __match_args__: Final = ("name", "lock", "version") @property def name(self) -> _ThreadInfoName: ... @@ -326,8 +318,7 @@ _ReleaseLevel: TypeAlias = Literal["alpha", "beta", "candidate", "final"] @final @type_check_only class _version_info(_UninstantiableStructseq, tuple[int, int, int, _ReleaseLevel, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") + __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") @property def major(self) -> int: ... @@ -467,8 +458,7 @@ _AsyncgenHook: TypeAlias = Callable[[AsyncGenerator[Any, Any]], None] | None @final @type_check_only class _asyncgen_hooks(structseq[_AsyncgenHook], tuple[_AsyncgenHook, _AsyncgenHook]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("firstiter", "finalizer") + __match_args__: Final = ("firstiter", "finalizer") @property def firstiter(self) -> _AsyncgenHook: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index 8de7ddc4255f..19268ebb33fc 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -26,13 +26,11 @@ def get_config_vars() -> dict[str, Any]: ... @overload def get_config_vars(arg: str, /, *args: str) -> list[Any]: ... def get_scheme_names() -> tuple[str, ...]: ... +def get_default_scheme() -> LiteralString: ... +def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... -if sys.version_info >= (3, 10): - def get_default_scheme() -> LiteralString: ... - def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... - # Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes - def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... - +# Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes +def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> dict[str, str]: ... diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 26491074ff71..1e8e8679add5 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -421,7 +421,7 @@ class TemporaryDirectory(Generic[AnyStr]): *, delete: bool = True, ) -> None: ... - elif sys.version_info >= (3, 10): + else: @overload def __init__( self: TemporaryDirectory[str], @@ -438,18 +438,6 @@ class TemporaryDirectory(Generic[AnyStr]): dir: BytesPath | None = None, ignore_cleanup_errors: bool = False, ) -> None: ... - else: - @overload - def __init__( - self: TemporaryDirectory[str], suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None - ) -> None: ... - @overload - def __init__( - self: TemporaryDirectory[bytes], - suffix: bytes | None = None, - prefix: bytes | None = None, - dir: BytesPath | None = None, - ) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 03c8865d3c0a..bd9bf7693824 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -29,6 +29,8 @@ __all__ = [ "Timer", "ThreadError", "ExceptHookArgs", + "getprofile", + "gettrace", "setprofile", "settrace", "local", @@ -37,9 +39,6 @@ __all__ = [ "get_native_id", ] -if sys.version_info >= (3, 10): - __all__ += ["getprofile", "gettrace"] - if sys.version_info >= (3, 12): __all__ += ["setprofile_all_threads", "settrace_all_threads"] @@ -61,10 +60,8 @@ if sys.version_info >= (3, 12): def setprofile_all_threads(func: ProfileFunction | None) -> None: ... def settrace_all_threads(func: TraceFunction | None) -> None: ... -if sys.version_info >= (3, 10): - def gettrace() -> TraceFunction | None: ... - def getprofile() -> ProfileFunction | None: ... - +def gettrace() -> TraceFunction | None: ... +def getprofile() -> ProfileFunction | None: ... def stack_size(size: int = 0, /) -> int: ... TIMEOUT_MAX: Final[float] @@ -173,8 +170,7 @@ class Event: def wait(self, timeout: float | None = None) -> bool: ... excepthook: Callable[[_ExceptHookArgs], object] -if sys.version_info >= (3, 10): - __excepthook__: Callable[[_ExceptHookArgs], object] +__excepthook__: Callable[[_ExceptHookArgs], object] ExceptHookArgs = _ExceptHookArgs class Timer(Thread): diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 64a009318894..a276e9167f76 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -47,8 +47,7 @@ if sys.platform == "linux": # https://github.com/python/typeshed/pull/6560#discussion_r767162532 @final class struct_time(structseq[Any | int], _TimeTuple): - if sys.version_info >= (3, 10): - __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") + __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") @property def tm_year(self) -> int: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 327ba7a2432e..9abfd7ba6085 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,6 +1,5 @@ import _tkinter import itertools -import sys import tkinter from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only from typing_extensions import TypeAlias, Unpack @@ -112,9 +111,4 @@ class Font: def families(root: tkinter.Misc | None = None, displayof: tkinter.Misc | None = None) -> tuple[str, ...]: ... def names(root: tkinter.Misc | None = None) -> tuple[str, ...]: ... - -if sys.version_info >= (3, 10): - def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... - -else: - def nametofont(name: str) -> Font: ... +def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... diff --git a/stdlib/token.pyi b/stdlib/token.pyi index fd1b10da1d12..23b43250d60f 100644 --- a/stdlib/token.pyi +++ b/stdlib/token.pyi @@ -57,6 +57,7 @@ __all__ = [ "SEMI", "SLASH", "SLASHEQUAL", + "SOFT_KEYWORD", "STAR", "STAREQUAL", "STRING", @@ -73,9 +74,6 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -if sys.version_info >= (3, 10): - __all__ += ["SOFT_KEYWORD"] - if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] @@ -150,8 +148,7 @@ TYPE_COMMENT: Final[int] TYPE_IGNORE: Final[int] COLONEQUAL: Final[int] EXACT_TOKEN_TYPES: Final[dict[str, int]] -if sys.version_info >= (3, 10): - SOFT_KEYWORD: Final[int] +SOFT_KEYWORD: Final[int] if sys.version_info >= (3, 12): EXCLAMATION: Final[int] diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 0df8062d5689..eb7318a9f5e7 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -71,6 +71,7 @@ __all__ = [ "SEMI", "SLASH", "SLASHEQUAL", + "SOFT_KEYWORD", "STAR", "STAREQUAL", "STRING", @@ -89,9 +90,6 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -if sys.version_info >= (3, 10): - __all__ += ["SOFT_KEYWORD"] - if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index f9d88f25afd9..b079dbafc92c 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -33,51 +33,31 @@ if sys.version_info >= (3, 14): _FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None] def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... - -if sys.version_info >= (3, 10): - @overload - def print_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - file: SupportsWrite[str] | None = None, - chain: bool = True, - ) -> None: ... - @overload - def print_exception( - exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True - ) -> None: ... - @overload - def format_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - chain: bool = True, - ) -> list[str]: ... - @overload - def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... - -else: - def print_exception( - etype: type[BaseException] | None, - value: BaseException | None, - tb: TracebackType | None, - limit: int | None = None, - file: SupportsWrite[str] | None = None, - chain: bool = True, - ) -> None: ... - def format_exception( - etype: type[BaseException] | None, - value: BaseException | None, - tb: TracebackType | None, - limit: int | None = None, - chain: bool = True, - ) -> list[str]: ... - +@overload +def print_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + file: SupportsWrite[str] | None = None, + chain: bool = True, +) -> None: ... +@overload +def print_exception( + exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True +) -> None: ... +@overload +def format_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + chain: bool = True, +) -> list[str]: ... +@overload +def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... def print_exc(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_last(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_stack(f: FrameType | None = None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... @@ -92,15 +72,12 @@ if sys.version_info >= (3, 13): @overload def format_exception_only(exc: Unused, /, value: BaseException | None, *, show_group: bool = False) -> list[str]: ... -elif sys.version_info >= (3, 10): +else: @overload def format_exception_only(exc: BaseException | None, /) -> list[str]: ... @overload def format_exception_only(exc: Unused, /, value: BaseException | None) -> list[str]: ... -else: - def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... - def format_exc(limit: int | None = None, chain: bool = True) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = None) -> list[str]: ... def format_stack(f: FrameType | None = None, limit: int | None = None) -> list[str]: ... @@ -126,12 +103,10 @@ class TracebackException: # These fields only exist for `SyntaxError`s, but there is no way to express that in the type system. filename: str lineno: str | None - if sys.version_info >= (3, 10): - end_lineno: str | None + end_lineno: str | None text: str offset: int - if sys.version_info >= (3, 10): - end_offset: int | None + end_offset: int | None msg: str if sys.version_info >= (3, 13): @@ -173,19 +148,6 @@ class TracebackException: max_group_depth: int = 10, _seen: set[int] | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - exc_type: type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType | None, - *, - limit: int | None = None, - lookup_lines: bool = True, - capture_locals: bool = False, - compact: bool = False, - _seen: set[int] | None = None, - ) -> None: ... else: def __init__( self, @@ -196,6 +158,7 @@ class TracebackException: limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False, + compact: bool = False, _seen: set[int] | None = None, ) -> None: ... @@ -212,7 +175,7 @@ class TracebackException: max_group_width: int = 15, max_group_depth: int = 10, ) -> Self: ... - elif sys.version_info >= (3, 10): + else: @classmethod def from_exception( cls, @@ -223,11 +186,6 @@ class TracebackException: capture_locals: bool = False, compact: bool = False, ) -> Self: ... - else: - @classmethod - def from_exception( - cls, exc: BaseException, *, limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False - ) -> Self: ... def __eq__(self, other: object) -> bool: ... __hash__: ClassVar[None] # type: ignore[assignment] diff --git a/stdlib/types.pyi b/stdlib/types.pyi index e26c9447d2f7..366a1189ed82 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -50,11 +50,12 @@ __all__ = [ "resolve_bases", "CellType", "GenericAlias", + "EllipsisType", + "NoneType", + "NotImplementedType", + "UnionType", ] -if sys.version_info >= (3, 10): - __all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] - if sys.version_info >= (3, 12): __all__ += ["get_original_bases"] @@ -84,9 +85,8 @@ class FunctionType: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -149,22 +149,16 @@ class CodeType: def co_name(self) -> str: ... @property def co_firstlineno(self) -> int: ... - if sys.version_info >= (3, 10): - @property - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") - def co_lnotab(self) -> bytes: ... - else: - @property - def co_lnotab(self) -> bytes: ... - + @property + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") + def co_lnotab(self) -> bytes: ... @property def co_freevars(self) -> tuple[str, ...]: ... @property def co_cellvars(self) -> tuple[str, ...]: ... - if sys.version_info >= (3, 10): - @property - def co_linetable(self) -> bytes: ... - def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... + @property + def co_linetable(self) -> bytes: ... + def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... if sys.version_info >= (3, 11): @property def co_exceptiontable(self) -> bytes: ... @@ -197,27 +191,6 @@ class CodeType: cellvars: tuple[str, ...] = ..., /, ) -> Self: ... - elif sys.version_info >= (3, 10): - def __new__( - cls, - argcount: int, - posonlyargcount: int, - kwonlyargcount: int, - nlocals: int, - stacksize: int, - flags: int, - codestring: bytes, - constants: tuple[object, ...], - names: tuple[str, ...], - varnames: tuple[str, ...], - filename: str, - name: str, - firstlineno: int, - linetable: bytes, - freevars: tuple[str, ...] = ..., - cellvars: tuple[str, ...] = ..., - /, - ) -> Self: ... else: def __new__( cls, @@ -234,7 +207,7 @@ class CodeType: filename: str, name: str, firstlineno: int, - lnotab: bytes, + linetable: bytes, freevars: tuple[str, ...] = ..., cellvars: tuple[str, ...] = ..., /, @@ -262,27 +235,6 @@ class CodeType: co_linetable: bytes = ..., co_exceptiontable: bytes = ..., ) -> Self: ... - elif sys.version_info >= (3, 10): - def replace( - self, - *, - co_argcount: int = -1, - co_posonlyargcount: int = -1, - co_kwonlyargcount: int = -1, - co_nlocals: int = -1, - co_stacksize: int = -1, - co_flags: int = -1, - co_firstlineno: int = -1, - co_code: bytes = ..., - co_consts: tuple[object, ...] = ..., - co_names: tuple[str, ...] = ..., - co_varnames: tuple[str, ...] = ..., - co_freevars: tuple[str, ...] = ..., - co_cellvars: tuple[str, ...] = ..., - co_filename: str = ..., - co_name: str = ..., - co_linetable: bytes = ..., - ) -> Self: ... else: def replace( self, @@ -302,7 +254,7 @@ class CodeType: co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., - co_lnotab: bytes = ..., + co_linetable: bytes = ..., ) -> Self: ... if sys.version_info >= (3, 13): @@ -697,43 +649,42 @@ class GenericAlias: def __unpacked__(self) -> bool: ... @property def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ... - if sys.version_info >= (3, 10): - def __or__(self, value: Any, /) -> UnionType: ... - def __ror__(self, value: Any, /) -> UnionType: ... + + def __or__(self, value: Any, /) -> UnionType: ... + def __ror__(self, value: Any, /) -> UnionType: ... # GenericAlias delegates attr access to `__origin__` def __getattr__(self, name: str) -> Any: ... -if sys.version_info >= (3, 10): - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... +@final +class NoneType: + def __bool__(self) -> Literal[False]: ... - @final - class EllipsisType: ... +@final +class EllipsisType: ... - @final - class NotImplementedType(Any): ... +@final +class NotImplementedType(Any): ... - @final - class UnionType: - @property - def __args__(self) -> tuple[Any, ...]: ... - @property - def __parameters__(self) -> tuple[Any, ...]: ... - # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). - # Normally we'd express this using the return type of `_SpecialForm.__ror__`, - # but because `UnionType.__or__` accepts `Any`, type checkers will use - # the return type of `UnionType.__or__` to infer the result of this operation - # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` - # in the return type of `UnionType.__(r)or__`. - def __or__(self, value: Any, /) -> UnionType | Any: ... - def __ror__(self, value: Any, /) -> UnionType | Any: ... - def __eq__(self, value: object, /) -> bool: ... - def __hash__(self) -> int: ... - # you can only subscript a `UnionType` instance if at least one of the elements - # in the union is a generic alias instance that has a non-empty `__parameters__` - def __getitem__(self, parameters: Any, /) -> object: ... +@final +class UnionType: + @property + def __args__(self) -> tuple[Any, ...]: ... + @property + def __parameters__(self) -> tuple[Any, ...]: ... + # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). + # Normally we'd express this using the return type of `_SpecialForm.__ror__`, + # but because `UnionType.__or__` accepts `Any`, type checkers will use + # the return type of `UnionType.__or__` to infer the result of this operation + # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` + # in the return type of `UnionType.__(r)or__`. + def __or__(self, value: Any, /) -> UnionType | Any: ... + def __ror__(self, value: Any, /) -> UnionType | Any: ... + def __eq__(self, value: object, /) -> bool: ... + def __hash__(self) -> int: ... + # you can only subscript a `UnionType` instance if at least one of the elements + # in the union is a generic alias instance that has a non-empty `__parameters__` + def __getitem__(self, parameters: Any, /) -> object: ... if sys.version_info >= (3, 13): @final diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index af1d1650da41..886c13016016 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -18,6 +18,7 @@ from types import ( MethodWrapperType, ModuleType, TracebackType, + UnionType, WrapperDescriptorType, ) from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, deprecated @@ -27,9 +28,6 @@ if sys.version_info >= (3, 14): from annotationlib import Format -if sys.version_info >= (3, 10): - from types import UnionType - __all__ = [ "AbstractSet", "Annotated", @@ -46,6 +44,7 @@ __all__ = [ "ChainMap", "ClassVar", "Collection", + "Concatenate", "Container", "ContextManager", "Coroutine", @@ -77,6 +76,9 @@ __all__ = [ "NoReturn", "Optional", "OrderedDict", + "ParamSpec", + "ParamSpecArgs", + "ParamSpecKwargs", "Pattern", "Protocol", "Reversible", @@ -94,6 +96,8 @@ __all__ = [ "TextIO", "Tuple", "Type", + "TypeAlias", + "TypeGuard", "TypeVar", "TypedDict", "Union", @@ -104,6 +108,7 @@ __all__ = [ "get_args", "get_origin", "get_type_hints", + "is_typeddict", "no_type_check", "no_type_check_decorator", "overload", @@ -113,9 +118,6 @@ __all__ = [ if sys.version_info >= (3, 14): __all__ += ["evaluate_forward_ref"] -if sys.version_info >= (3, 10): - __all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] - if sys.version_info >= (3, 11): __all__ += [ "LiteralString", @@ -206,9 +208,9 @@ class TypeVar: covariant: bool = False, contravariant: bool = False, ) -> None: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm - def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm + + def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm + def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any, /) -> Any: ... if sys.version_info >= (3, 13): @@ -227,9 +229,8 @@ class TypeVar: class _SpecialForm(_Final): __slots__ = ("_name", "__doc__", "_getitem") def __getitem__(self, parameters: Any) -> object: ... - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... Union: _SpecialForm Protocol: _SpecialForm @@ -275,122 +276,108 @@ if sys.version_info >= (3, 11): @property def evaluate_default(self) -> EvaluateFunc | None: ... -if sys.version_info >= (3, 10): - @final - class ParamSpecArgs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... - - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpecArgs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - @final - class ParamSpecKwargs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpecKwargs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - @final - class ParamSpec: - @property - def __name__(self) -> str: ... - @property - def __bound__(self) -> Any | None: ... # AnnotationForm - @property - def __covariant__(self) -> bool: ... - @property - def __contravariant__(self) -> bool: ... - if sys.version_info >= (3, 12): - @property - def __infer_variance__(self) -> bool: ... - if sys.version_info >= (3, 13): - @property - def __default__(self) -> Any: ... # AnnotationForm - if sys.version_info >= (3, 13): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - default: Any = ..., # AnnotationForm - ) -> Self: ... - elif sys.version_info >= (3, 12): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - ) -> Self: ... - elif sys.version_info >= (3, 11): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - ) -> Self: ... - else: - def __init__( - self, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - ) -> None: ... + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpec: + @property + def __name__(self) -> str: ... + @property + def __bound__(self) -> Any | None: ... # AnnotationForm + @property + def __covariant__(self) -> bool: ... + @property + def __contravariant__(self) -> bool: ... + if sys.version_info >= (3, 12): @property - def args(self) -> ParamSpecArgs: ... + def __infer_variance__(self) -> bool: ... + if sys.version_info >= (3, 13): @property - def kwargs(self) -> ParamSpecKwargs: ... - if sys.version_info >= (3, 11): - def __typing_subst__(self, arg: Any, /) -> Any: ... - def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... + def __default__(self) -> Any: ... # AnnotationForm + if sys.version_info >= (3, 13): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + default: Any = ..., # AnnotationForm + ) -> Self: ... + elif sys.version_info >= (3, 12): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + ) -> Self: ... + elif sys.version_info >= (3, 11): + def __new__( + cls, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm + ) -> Self: ... + else: + def __init__( + self, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm + ) -> None: ... - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... - if sys.version_info >= (3, 13): - def has_default(self) -> bool: ... - if sys.version_info >= (3, 14): - @property - def evaluate_default(self) -> EvaluateFunc | None: ... + @property + def args(self) -> ParamSpecArgs: ... + @property + def kwargs(self) -> ParamSpecKwargs: ... + if sys.version_info >= (3, 11): + def __typing_subst__(self, arg: Any, /) -> Any: ... + def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... + if sys.version_info >= (3, 13): + def has_default(self) -> bool: ... + if sys.version_info >= (3, 14): + @property + def evaluate_default(self) -> EvaluateFunc | None: ... - class NewType: - def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm - if sys.version_info >= (3, 11): - @staticmethod - def __call__(x: _T, /) -> _T: ... - else: - def __call__(self, x: _T) -> _T: ... +Concatenate: _SpecialForm +TypeAlias: _SpecialForm +TypeGuard: _SpecialForm - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - __supertype__: type | NewType - __name__: str +class NewType: + def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm + if sys.version_info >= (3, 11): + @staticmethod + def __call__(x: _T, /) -> _T: ... + else: + def __call__(self, x: _T) -> _T: ... -else: - def NewType(name: str, tp: Any) -> Any: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... + __supertype__: type | NewType + __name__: str _F = TypeVar("_F", bound=Callable[..., Any]) _P = _ParamSpec("_P") @@ -448,12 +435,8 @@ class _Generic: if sys.version_info < (3, 12): __slots__ = () - if sys.version_info >= (3, 10): - @classmethod - def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... - else: - @classmethod - def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... + @classmethod + def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... Generic: type[_Generic] @@ -973,13 +956,10 @@ else: ) -> dict[str, Any]: ... # AnnotationForm def get_args(tp: Any) -> tuple[Any, ...]: ... # AnnotationForm - -if sys.version_info >= (3, 10): - @overload - def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... - @overload - def get_origin(tp: UnionType) -> type[UnionType]: ... - +@overload +def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... +@overload +def get_origin(tp: UnionType) -> type[UnionType]: ... @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -1142,9 +1122,7 @@ else: def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... -if sys.version_info >= (3, 10): - def is_typeddict(tp: object) -> bool: ... - +def is_typeddict(tp: object) -> bool: ... def _type_repr(obj: object) -> str: ... if sys.version_info >= (3, 12): diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 406005cc4c56..9fcdf9d8030a 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -29,7 +29,7 @@ from collections.abc import ( ) from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager from re import Match as Match, Pattern as Pattern -from types import GenericAlias, ModuleType +from types import GenericAlias, ModuleType, UnionType from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035,RUF100 IO as IO, TYPE_CHECKING as TYPE_CHECKING, @@ -40,6 +40,7 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035,RUF100 Callable as Callable, ChainMap as ChainMap, ClassVar as ClassVar, + Concatenate as Concatenate, Counter as Counter, DefaultDict as DefaultDict, Deque as Deque, @@ -50,26 +51,28 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035,RUF100 List as List, NoReturn as NoReturn, Optional as Optional, + ParamSpecArgs as ParamSpecArgs, + ParamSpecKwargs as ParamSpecKwargs, Set as Set, Text as Text, TextIO as TextIO, Tuple as Tuple, Type as Type, + TypeAlias as TypeAlias, TypedDict as TypedDict, + TypeGuard as TypeGuard, TypeVar as _TypeVar, Union as Union, _Alias, _SpecialForm, cast as cast, + is_typeddict as is_typeddict, no_type_check as no_type_check, no_type_check_decorator as no_type_check_decorator, overload as overload, type_check_only, ) -if sys.version_info >= (3, 10): - from types import UnionType - # Please keep order the same as at runtime. __all__ = [ # Super-special typing primitives. @@ -274,11 +277,8 @@ else: ) -> dict[str, AnnotationForm]: ... def get_args(tp: AnnotationForm) -> tuple[AnnotationForm, ...]: ... - -if sys.version_info >= (3, 10): - @overload - def get_origin(tp: UnionType) -> type[UnionType]: ... - +@overload +def get_origin(tp: UnionType) -> type[UnionType]: ... @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -289,34 +289,6 @@ def get_origin(tp: AnnotationForm) -> AnnotationForm | None: ... Annotated: _SpecialForm _AnnotatedAlias: Any # undocumented -# New and changed things in 3.10 -if sys.version_info >= (3, 10): - from typing import ( - Concatenate as Concatenate, - ParamSpecArgs as ParamSpecArgs, - ParamSpecKwargs as ParamSpecKwargs, - TypeAlias as TypeAlias, - TypeGuard as TypeGuard, - is_typeddict as is_typeddict, - ) -else: - @final - class ParamSpecArgs: - @property - def __origin__(self) -> ParamSpec: ... - def __init__(self, origin: ParamSpec) -> None: ... - - @final - class ParamSpecKwargs: - @property - def __origin__(self) -> ParamSpec: ... - def __init__(self, origin: ParamSpec) -> None: ... - - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm - def is_typeddict(tp: object) -> bool: ... - # New and changed things in 3.11 if sys.version_info >= (3, 11): from typing import ( @@ -375,11 +347,10 @@ else: class NewType: def __init__(self, name: str, tp: AnnotationForm) -> None: ... def __call__(self, obj: _T, /) -> _T: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... __supertype__: type | NewType __name__: str - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... if sys.version_info >= (3, 12): from collections.abc import Buffer as Buffer @@ -527,9 +498,8 @@ else: ) -> None: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any) -> Any: ... @@ -556,15 +526,14 @@ else: covariant: bool = False, default: AnnotationForm = ..., ) -> None: ... + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... @property def args(self) -> ParamSpecArgs: ... @property def kwargs(self) -> ParamSpecKwargs: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... @final class TypeVarTuple: @@ -605,9 +574,8 @@ else: # Returns typing._GenericAlias, which isn't stubbed. def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ... def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... # PEP 727 class Doc: @@ -705,6 +673,6 @@ class Sentinel: if sys.version_info >= (3, 14): def __or__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions - elif sys.version_info >= (3, 10): + else: def __or__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index 9fff042f0b96..717856302ae0 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -1,14 +1,10 @@ -import sys from _typeshed import ReadOnlyBuffer -from typing import Any, Final, Literal, TypeVar, final, overload +from typing import Final, Literal, TypeVar, final, overload from typing_extensions import TypeAlias ucd_3_2_0: UCD unidata_version: Final[str] -if sys.version_info < (3, 10): - ucnhash_CAPI: Any - _T = TypeVar("_T") _NormalizationForm: TypeAlias = Literal["NFC", "NFD", "NFKC", "NFKD"] diff --git a/stdlib/unittest/_log.pyi b/stdlib/unittest/_log.pyi index 011a970d8bbc..09ba7d945025 100644 --- a/stdlib/unittest/_log.pyi +++ b/stdlib/unittest/_log.pyi @@ -1,5 +1,4 @@ import logging -import sys from types import TracebackType from typing import ClassVar, Generic, NamedTuple, TypeVar from unittest.case import TestCase, _BaseTestCaseContext @@ -15,12 +14,8 @@ class _AssertLogsContext(_BaseTestCaseContext, Generic[_L]): logger_name: str level: int msg: None - if sys.version_info >= (3, 10): - def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... - no_logs: bool - else: - def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... - + no_logs: bool + def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... def __enter__(self) -> _L: ... def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 7a02bdfe76b4..3975201e7c2c 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -168,11 +168,9 @@ class TestCase: def assertLogs( self, logger: str | logging.Logger | None = None, level: int | str | None = None ) -> _AssertLogsContext[_LoggingWatcher]: ... - if sys.version_info >= (3, 10): - def assertNoLogs( - self, logger: str | logging.Logger | None = None, level: int | str | None = None - ) -> _AssertLogsContext[None]: ... - + def assertNoLogs( + self, logger: str | logging.Logger | None = None, level: int | str | None = None + ) -> _AssertLogsContext[None]: ... @overload def assertAlmostEqual(self, first: _S, second: _S, places: None, msg: Any, delta: _SupportsAbsAndDunderGE) -> None: ... @overload @@ -277,9 +275,8 @@ class TestCase: self, subset: Mapping[Any, Any], dictionary: Mapping[Any, Any], msg: object = None ) -> None: ... - if sys.version_info >= (3, 10): - # Runtime has *args, **kwargs, but will error if any are supplied - def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... + # Runtime has *args, **kwargs, but will error if any are supplied + def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... if sys.version_info >= (3, 14): def assertIsSubclass(self, cls: type, superclass: type | tuple[type, ...], msg: Any = None) -> None: ... diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index ef51d721297a..ab8c173f2d3b 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -244,35 +244,20 @@ class _patch(Generic[_T]): additional_patchers: Any # If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock], # but that's impossible with the current type system. - if sys.version_info >= (3, 10): - def __init__( - self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 - getter: Callable[[], Any], - attribute: str, - new: _T, - spec: Any | None, - create: bool, - spec_set: Any | None, - autospec: Any | None, - new_callable: Any | None, - kwargs: Mapping[str, Any], - *, - unsafe: bool = False, - ) -> None: ... - else: - def __init__( - self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 - getter: Callable[[], Any], - attribute: str, - new: _T, - spec: Any | None, - create: bool, - spec_set: Any | None, - autospec: Any | None, - new_callable: Any | None, - kwargs: Mapping[str, Any], - ) -> None: ... - + def __init__( + self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 + getter: Callable[[], Any], + attribute: str, + new: _T, + spec: Any | None, + create: bool, + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, + kwargs: Mapping[str, Any], + *, + unsafe: bool = False, + ) -> None: ... def copy(self) -> _patch[_T]: ... @overload def __call__(self, func: _TT) -> _TT: ... @@ -315,13 +300,11 @@ class _patch_dict: clear: Any def __init__(self, in_dict: Any, values: Any = (), clear: Any = False, **kwargs: Any) -> None: ... def __call__(self, f: Any) -> Any: ... - if sys.version_info >= (3, 10): - def decorate_callable(self, f: _F) -> _F: ... - def decorate_async_callable(self, f: _AF) -> _AF: ... - - def decorate_class(self, klass: Any) -> Any: ... def __enter__(self) -> Any: ... def __exit__(self, *args: object) -> Any: ... + def decorate_callable(self, f: _F) -> _F: ... + def decorate_async_callable(self, f: _AF) -> _AF: ... + def decorate_class(self, klass: Any) -> Any: ... start: Any stop: Any @@ -517,27 +500,16 @@ class _ANY(Any): ANY: _ANY -if sys.version_info >= (3, 10): - def create_autospec( - spec: Any, - spec_set: Any = False, - instance: Any = False, - _parent: Any | None = None, - _name: Any | None = None, - *, - unsafe: bool = False, - **kwargs: Any, - ) -> Any: ... - -else: - def create_autospec( - spec: Any, - spec_set: Any = False, - instance: Any = False, - _parent: Any | None = None, - _name: Any | None = None, - **kwargs: Any, - ) -> Any: ... +def create_autospec( + spec: Any, + spec_set: Any = False, + instance: Any = False, + _parent: Any | None = None, + _name: Any | None = None, + *, + unsafe: bool = False, + **kwargs: Any, +) -> Any: ... class _SpecState: spec: Any diff --git a/stdlib/xml/sax/expatreader.pyi b/stdlib/xml/sax/expatreader.pyi index 3f9573a25f9a..472b6048b2ff 100644 --- a/stdlib/xml/sax/expatreader.pyi +++ b/stdlib/xml/sax/expatreader.pyi @@ -1,13 +1,9 @@ -import sys from _typeshed import ReadableBuffer from collections.abc import Mapping from typing import Any, Final, Literal, overload from typing_extensions import TypeAlias from xml.sax import _Source, xmlreader -from xml.sax.handler import _ContentHandlerProtocol - -if sys.version_info >= (3, 10): - from xml.sax.handler import LexicalHandler +from xml.sax.handler import LexicalHandler, _ContentHandlerProtocol _BoolType: TypeAlias = Literal[0, 1] | bool @@ -33,20 +29,16 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): def setContentHandler(self, handler: _ContentHandlerProtocol) -> None: ... def getFeature(self, name: str) -> _BoolType: ... def setFeature(self, name: str, state: _BoolType) -> None: ... - if sys.version_info >= (3, 10): - @overload - def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... - + @overload + def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... @overload def getProperty(self, name: Literal["http://www.python.org/sax/properties/interning-dict"]) -> dict[str, Any] | None: ... @overload def getProperty(self, name: Literal["http://xml.org/sax/properties/xml-string"]) -> bytes | None: ... @overload def getProperty(self, name: str) -> object: ... - if sys.version_info >= (3, 10): - @overload - def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... - + @overload + def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... @overload def setProperty( self, name: Literal["http://www.python.org/sax/properties/interning-dict"], value: dict[str, Any] diff --git a/stdlib/xml/sax/handler.pyi b/stdlib/xml/sax/handler.pyi index 5ecbfa6f1272..e1e080ac2d1a 100644 --- a/stdlib/xml/sax/handler.pyi +++ b/stdlib/xml/sax/handler.pyi @@ -1,4 +1,3 @@ -import sys from typing import Final, NoReturn, Protocol, type_check_only from xml.sax import xmlreader @@ -77,10 +76,9 @@ property_encoding: Final = "http://www.python.org/sax/properties/encoding" property_interning_dict: Final[str] # too long string all_properties: Final[list[str]] -if sys.version_info >= (3, 10): - class LexicalHandler: - def comment(self, content: str) -> None: ... - def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... - def endDTD(self) -> None: ... - def startCDATA(self) -> None: ... - def endCDATA(self) -> None: ... +class LexicalHandler: + def comment(self, content: str) -> None: ... + def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... + def endDTD(self) -> None: ... + def startCDATA(self) -> None: ... + def endCDATA(self) -> None: ... diff --git a/stdlib/xxlimited.pyi b/stdlib/xxlimited.pyi index 78a50b85f405..503caf0183f3 100644 --- a/stdlib/xxlimited.pyi +++ b/stdlib/xxlimited.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, ClassVar, final +from typing import Any, final class Str(str): ... @@ -12,13 +12,4 @@ class Xxo: def foo(i: int, j: int, /) -> Any: ... def new() -> Xxo: ... -if sys.version_info >= (3, 10): - class Error(Exception): ... - -else: - class error(Exception): ... - - class Null: - __hash__: ClassVar[None] # type: ignore[assignment] - - def roj(b: Any, /) -> None: ... +class Error(Exception): ... diff --git a/stdlib/zipfile/__init__.pyi b/stdlib/zipfile/__init__.pyi index 19d8117a621f..f618d88fd143 100644 --- a/stdlib/zipfile/__init__.pyi +++ b/stdlib/zipfile/__init__.pyi @@ -345,9 +345,8 @@ else: def name(self) -> str: ... @property def parent(self) -> PathLike[str]: ... # undocumented - if sys.version_info >= (3, 10): - @property - def filename(self) -> PathLike[str]: ... # undocumented + @property + def filename(self) -> PathLike[str]: ... # undocumented if sys.version_info >= (3, 11): @property def suffix(self) -> str: ... @@ -370,12 +369,7 @@ else: ) -> TextIOWrapper: ... @overload def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ... - - if sys.version_info >= (3, 10): - def iterdir(self) -> Iterator[Self]: ... - else: - def iterdir(self) -> Iterator[Path]: ... - + def iterdir(self) -> Iterator[Self]: ... def is_dir(self) -> bool: ... def is_file(self) -> bool: ... def exists(self) -> bool: ... @@ -388,11 +382,7 @@ else: write_through: bool = False, ) -> str: ... def read_bytes(self) -> bytes: ... - if sys.version_info >= (3, 10): - def joinpath(self, *other: StrPath) -> Path: ... - else: - def joinpath(self, add: StrPath) -> Path: ... # undocumented - + def joinpath(self, *other: StrPath) -> Path: ... def __truediv__(self, add: StrPath) -> Path: ... def is_zipfile(filename: StrOrBytesPath | _SupportsReadSeekTell) -> bool: ... diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 22af3c272759..f660684d351e 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -1,19 +1,11 @@ import sys +from _frozen_importlib_external import _LoaderBasics from _typeshed import StrOrBytesPath from importlib.machinery import ModuleSpec +from importlib.readers import ZipReader from types import CodeType, ModuleType from typing_extensions import deprecated -if sys.version_info >= (3, 10): - from importlib.readers import ZipReader -else: - from importlib.abc import ResourceReader - -if sys.version_info >= (3, 10): - from _frozen_importlib_external import _LoaderBasics -else: - _LoaderBasics = object - __all__ = ["ZipImportError", "zipimporter"] class ZipImportError(ImportError): ... @@ -27,33 +19,24 @@ class zipimporter(_LoaderBasics): def __init__(self, path: StrOrBytesPath) -> None: ... if sys.version_info < (3, 12): - 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: ... + @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: ... def get_data(self, pathname: str) -> bytes: ... def get_filename(self, fullname: str) -> str: ... if sys.version_info >= (3, 14): def get_resource_reader(self, fullname: str) -> ZipReader: ... # undocumented - elif sys.version_info >= (3, 10): - def get_resource_reader(self, fullname: str) -> ZipReader | None: ... # undocumented else: - def get_resource_reader(self, fullname: str) -> ResourceReader | None: ... # undocumented + def get_resource_reader(self, fullname: str) -> ZipReader | None: ... # undocumented def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... - 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: ... + @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: ... From 97bae091c82aa168d71991e233c1822810d25fe7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 17:39:58 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/importlib/resources/_common.pyi | 2 +- stdlib/inspect.pyi | 6 +++--- stdlib/ipaddress.pyi | 2 +- stdlib/os/__init__.pyi | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/stdlib/importlib/resources/_common.pyi b/stdlib/importlib/resources/_common.pyi index fdd7124f7521..11a93ca82d8d 100644 --- a/stdlib/importlib/resources/_common.pyi +++ b/stdlib/importlib/resources/_common.pyi @@ -16,7 +16,7 @@ if sys.version_info >= (3, 11): Anchor: TypeAlias = Package def package_to_anchor( - func: Callable[[Anchor | None], Traversable] + func: Callable[[Anchor | None], Traversable], ) -> Callable[[Anchor | None, Anchor | None], Traversable]: ... @overload def files(anchor: Anchor | None = None) -> Traversable: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index f67ea3699831..efaf2866eae8 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -406,7 +406,7 @@ if sys.version_info >= (3, 12): AGEN_CLOSED: Final = "AGEN_CLOSED" def getasyncgenstate( - agen: AsyncGenerator[Any, Any] + agen: AsyncGenerator[Any, Any], ) -> Literal["AGEN_CREATED", "AGEN_RUNNING", "AGEN_SUSPENDED", "AGEN_CLOSED"]: ... def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ... @@ -671,7 +671,7 @@ GEN_SUSPENDED: Final = "GEN_SUSPENDED" GEN_CLOSED: Final = "GEN_CLOSED" def getgeneratorstate( - generator: Generator[Any, Any, Any] + generator: Generator[Any, Any, Any], ) -> Literal["GEN_CREATED", "GEN_RUNNING", "GEN_SUSPENDED", "GEN_CLOSED"]: ... CORO_CREATED: Final = "CORO_CREATED" @@ -680,7 +680,7 @@ CORO_SUSPENDED: Final = "CORO_SUSPENDED" CORO_CLOSED: Final = "CORO_CLOSED" def getcoroutinestate( - coroutine: Coroutine[Any, Any, Any] + coroutine: Coroutine[Any, Any, Any], ) -> Literal["CORO_CREATED", "CORO_RUNNING", "CORO_SUSPENDED", "CORO_CLOSED"]: ... def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> dict[str, Any]: ... def getcoroutinelocals(coroutine: Coroutine[Any, Any, Any]) -> dict[str, Any]: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index c115420ca142..d09804cb9342 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -18,7 +18,7 @@ def ip_network( address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], strict: bool = True ) -> IPv4Network | IPv6Network: ... def ip_interface( - address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int] + address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], ) -> IPv4Interface | IPv6Interface: ... class _IPAddressBase: diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index b792e4328a0e..cdb01b0f7338 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -828,11 +828,9 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) if sys.version_info >= (3, 12) and sys.platform == "win32": @property - @deprecated( - """\ + @deprecated("""\ Use st_birthtime instead to retrieve the file creation time. \ -In the future, this property will contain the last metadata change time.""" - ) +In the future, this property will contain the last metadata change time.""") def st_ctime(self) -> float: ... else: @property From 841a1ac9aab814d209b2773290d62821a476e002 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 7 May 2026 19:44:08 +0200 Subject: [PATCH 3/3] Fix csv._writer import --- stubs/netaddr/netaddr/eui/ieee.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/netaddr/netaddr/eui/ieee.pyi b/stubs/netaddr/netaddr/eui/ieee.pyi index a5f2079af176..4c54532c2811 100644 --- a/stubs/netaddr/netaddr/eui/ieee.pyi +++ b/stubs/netaddr/netaddr/eui/ieee.pyi @@ -11,7 +11,7 @@ OUI_INDEX: _INDEX IAB_INDEX: _INDEX class FileIndexer(Subscriber): - writer: _csv._writer + writer: _csv.Writer def __init__(self, index_file: TextIO | FileDescriptorOrPath) -> None: ... def update(self, data: Iterable[Any]) -> None: ...