From 100d9dd2c6b2b648c09b882fed7d2699ab600c65 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 11 May 2022 17:12:49 +0100 Subject: [PATCH 1/5] Update csv.pyi --- stdlib/csv.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index de69c71ad941..1aa14f76e3dd 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -23,6 +23,7 @@ from _csv import ( ) from _typeshed import Self, SupportsWrite from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence +from types import GenericAlias from typing import Any, Generic, TypeVar, overload from typing_extensions import Literal @@ -121,6 +122,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 +154,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] From 9deea33d06233eadd409483cad0b997bb3b7c474 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 11 May 2022 17:15:54 +0100 Subject: [PATCH 2/5] Update __init__.pyi --- stdlib/logging/__init__.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 6ad4cd4f94e7..6a4994d4fbe0 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequenc from io import TextIOWrapper from string import Template from time import struct_time -from types import FrameType, TracebackType +from types import FrameType, GenericAlias, TracebackType from typing import Any, ClassVar, Generic, Pattern, TextIO, TypeVar, Union, overload from typing_extensions import Literal, TypeAlias @@ -593,6 +593,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 +771,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 From 1339ca5432e75dce0c5066b8c9e30faa5863b831 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 11 May 2022 17:31:53 +0100 Subject: [PATCH 3/5] Update csv.pyi --- stdlib/csv.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 1aa14f76e3dd..a7c246d25485 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -23,7 +23,6 @@ from _csv import ( ) from _typeshed import Self, SupportsWrite from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence -from types import GenericAlias from typing import Any, Generic, TypeVar, overload from typing_extensions import Literal @@ -32,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", From 40fdaca1bd60e229449fcb66fdd0ae3557474289 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 11 May 2022 17:32:50 +0100 Subject: [PATCH 4/5] Update __init__.pyi --- stdlib/logging/__init__.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 6a4994d4fbe0..ac7ae8c4ba16 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -5,10 +5,13 @@ from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequenc from io import TextIOWrapper from string import Template from time import struct_time -from types import FrameType, GenericAlias, TracebackType +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", From a960a70390e29c14b3432f72893c6f464384f8d9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 17 May 2022 05:50:46 -0700 Subject: [PATCH 5/5] Remove allowlist entries --- tests/stubtest_allowlists/py311.txt | 2 -- 1 file changed, 2 deletions(-) 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