Skip to content

Add __class_getitem__ to classes in logging and csv #7830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions stdlib/logging/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]: ...
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down