diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index de69c71ad941..a7c246d25485 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -31,6 +31,9 @@ if sys.version_info >= (3, 8): else: from collections import OrderedDict as _DictReadMapping +if sys.version_info >= (3, 12): + from types import GenericAlias + __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", @@ -121,6 +124,8 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): ) -> None: ... def __iter__(self: Self) -> Self: ... def __next__(self) -> _DictReadMapping[_T, str]: ... + if sys.version_info >= (3, 12): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... class DictWriter(Generic[_T]): fieldnames: Collection[_T] @@ -151,6 +156,8 @@ class DictWriter(Generic[_T]): def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... + if sys.version_info >= (3, 12): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... class Sniffer: preferred: list[str] diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 6ad4cd4f94e7..ac7ae8c4ba16 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -9,6 +9,9 @@ from types import FrameType, TracebackType from typing import Any, ClassVar, Generic, Pattern, TextIO, TypeVar, Union, overload from typing_extensions import Literal, TypeAlias +if sys.version_info >= (3, 11): + from types import GenericAlias + __all__ = [ "BASIC_FORMAT", "BufferingFormatter", @@ -593,6 +596,8 @@ class LoggerAdapter(Generic[_L]): ) -> None: ... # undocumented @property def name(self) -> str: ... # undocumented + if sys.version_info >= (3, 11): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... def getLogger(name: str | None = ...) -> Logger: ... def getLoggerClass() -> type[Logger]: ... @@ -769,6 +774,8 @@ class StreamHandler(Handler, Generic[_StreamT]): def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... if sys.version_info >= (3, 7): def setStream(self, stream: _StreamT) -> _StreamT | None: ... + if sys.version_info >= (3, 11): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... class FileHandler(StreamHandler[TextIOWrapper]): baseFilename: str # undocumented diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index 07c8c8a01896..5a1c2f9b938b 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -168,8 +168,6 @@ ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address ipaddress._BaseNetwork.hostmask locale.getencoding -logging.LoggerAdapter.__class_getitem__ -logging.StreamHandler.__class_getitem__ logging.getLevelNamesMapping logging.handlers.SysLogHandler.createSocket multiprocessing.managers.SharedMemoryServer.create