diff --git a/stdlib/_asyncio.pyi b/stdlib/_asyncio.pyi index 89cdff6cc283..be486fddb12d 100644 --- a/stdlib/_asyncio.pyi +++ b/stdlib/_asyncio.pyi @@ -2,13 +2,10 @@ import sys from asyncio.events import AbstractEventLoop from collections.abc import Awaitable, Callable, Coroutine, Generator from contextvars import Context -from types import FrameType +from types import FrameType, GenericAlias from typing import Any, Literal, TextIO, TypeVar from typing_extensions import Self, TypeAlias -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _TaskYieldType: TypeAlias = Future[object] | None @@ -29,11 +26,7 @@ class Future(Awaitable[_T]): @property def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ... def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ... - if sys.version_info >= (3, 9): - def cancel(self, msg: Any | None = None) -> bool: ... - else: - def cancel(self) -> bool: ... - + def cancel(self, msg: Any | None = None) -> bool: ... def cancelled(self) -> bool: ... def done(self) -> bool: ... def result(self) -> _T: ... @@ -45,15 +38,12 @@ class Future(Awaitable[_T]): def __await__(self) -> Generator[Any, None, _T]: ... @property def _loop(self) -> AbstractEventLoop: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... if sys.version_info >= (3, 12): _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] -elif sys.version_info >= (3, 9): - _TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co] else: - _TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co] + _TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co] # mypy and pyright complain that a subclass of an invariant class shouldn't be covariant. # While this is true in general, here it's sort-of okay to have a covariant subclass, @@ -99,13 +89,8 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn if sys.version_info >= (3, 11): def cancelling(self) -> int: ... def uncancel(self) -> int: ... - if sys.version_info < (3, 9): - @classmethod - def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ... - @classmethod - def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + + def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... def get_event_loop() -> AbstractEventLoop: ... def get_running_loop() -> AbstractEventLoop: ... diff --git a/stdlib/_blake2.pyi b/stdlib/_blake2.pyi index 3d17cb59c79b..d578df55c2fa 100644 --- a/stdlib/_blake2.pyi +++ b/stdlib/_blake2.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import ReadableBuffer from typing import ClassVar, final from typing_extensions import Self @@ -21,44 +20,24 @@ class blake2b: block_size: int digest_size: int name: str - if sys.version_info >= (3, 9): - def __new__( - cls, - data: ReadableBuffer = b"", - /, - *, - digest_size: int = 64, - key: ReadableBuffer = b"", - salt: ReadableBuffer = b"", - person: ReadableBuffer = b"", - fanout: int = 1, - depth: int = 1, - leaf_size: int = 0, - node_offset: int = 0, - node_depth: int = 0, - inner_size: int = 0, - last_node: bool = False, - usedforsecurity: bool = True, - ) -> Self: ... - else: - def __new__( - cls, - data: ReadableBuffer = b"", - /, - *, - digest_size: int = 64, - key: ReadableBuffer = b"", - salt: ReadableBuffer = b"", - person: ReadableBuffer = b"", - fanout: int = 1, - depth: int = 1, - leaf_size: int = 0, - node_offset: int = 0, - node_depth: int = 0, - inner_size: int = 0, - last_node: bool = False, - ) -> Self: ... - + def __new__( + cls, + data: ReadableBuffer = b"", + /, + *, + digest_size: int = 64, + key: ReadableBuffer = b"", + salt: ReadableBuffer = b"", + person: ReadableBuffer = b"", + fanout: int = 1, + depth: int = 1, + leaf_size: int = 0, + node_offset: int = 0, + node_depth: int = 0, + inner_size: int = 0, + last_node: bool = False, + usedforsecurity: bool = True, + ) -> Self: ... def copy(self) -> Self: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... @@ -73,44 +52,24 @@ class blake2s: block_size: int digest_size: int name: str - if sys.version_info >= (3, 9): - def __new__( - cls, - data: ReadableBuffer = b"", - /, - *, - digest_size: int = 32, - key: ReadableBuffer = b"", - salt: ReadableBuffer = b"", - person: ReadableBuffer = b"", - fanout: int = 1, - depth: int = 1, - leaf_size: int = 0, - node_offset: int = 0, - node_depth: int = 0, - inner_size: int = 0, - last_node: bool = False, - usedforsecurity: bool = True, - ) -> Self: ... - else: - def __new__( - cls, - data: ReadableBuffer = b"", - /, - *, - digest_size: int = 32, - key: ReadableBuffer = b"", - salt: ReadableBuffer = b"", - person: ReadableBuffer = b"", - fanout: int = 1, - depth: int = 1, - leaf_size: int = 0, - node_offset: int = 0, - node_depth: int = 0, - inner_size: int = 0, - last_node: bool = False, - ) -> Self: ... - + def __new__( + cls, + data: ReadableBuffer = b"", + /, + *, + digest_size: int = 32, + key: ReadableBuffer = b"", + salt: ReadableBuffer = b"", + person: ReadableBuffer = b"", + fanout: int = 1, + depth: int = 1, + leaf_size: int = 0, + node_offset: int = 0, + node_depth: int = 0, + inner_size: int = 0, + last_node: bool = False, + usedforsecurity: bool = True, + ) -> Self: ... def copy(self) -> Self: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 11c5d58a855b..89f97edb9ba8 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -81,26 +81,12 @@ def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> t def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ... def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... - -if sys.version_info >= (3, 9): - def raw_unicode_escape_decode( - data: str | ReadableBuffer, errors: str | None = None, final: bool = True, / - ) -> tuple[str, int]: ... - -else: - def raw_unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... - +def raw_unicode_escape_decode( + data: str | ReadableBuffer, errors: str | None = None, final: bool = True, / +) -> tuple[str, int]: ... def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ... - -if sys.version_info >= (3, 9): - def unicode_escape_decode( - data: str | ReadableBuffer, errors: str | None = None, final: bool = True, / - ) -> tuple[str, int]: ... - -else: - def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... - +def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ... def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... diff --git a/stdlib/_contextvars.pyi b/stdlib/_contextvars.pyi index c7d0814b3cb4..33df799a768c 100644 --- a/stdlib/_contextvars.pyi +++ b/stdlib/_contextvars.pyi @@ -1,11 +1,8 @@ -import sys from collections.abc import Callable, Iterator, Mapping +from types import GenericAlias from typing import Any, ClassVar, Generic, TypeVar, final, overload from typing_extensions import ParamSpec, Self -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _D = TypeVar("_D") _P = ParamSpec("_P") @@ -27,8 +24,7 @@ class ContextVar(Generic[_T]): def get(self, default: _D, /) -> _D | _T: ... def set(self, value: _T, /) -> Token[_T]: ... def reset(self, token: Token[_T], /) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @final class Token(Generic[_T]): @@ -38,8 +34,7 @@ class Token(Generic[_T]): def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express MISSING: ClassVar[object] __hash__: ClassVar[None] # type: ignore[assignment] - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... def copy_context() -> Context: ...