mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-10 10:26:31 +08:00
Add @type_check_only to stub-only private classes in stdlib (#14512)
This commit is contained in:
@@ -7,7 +7,7 @@ from re import Pattern
|
||||
from string import Template
|
||||
from time import struct_time
|
||||
from types import FrameType, GenericAlias, TracebackType
|
||||
from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload
|
||||
from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
@@ -67,11 +67,13 @@ _Level: TypeAlias = int | str
|
||||
_FormatStyle: TypeAlias = Literal["%", "{", "$"]
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
@type_check_only
|
||||
class _SupportsFilter(Protocol):
|
||||
def filter(self, record: LogRecord, /) -> bool | LogRecord: ...
|
||||
|
||||
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool | LogRecord] | _SupportsFilter
|
||||
else:
|
||||
@type_check_only
|
||||
class _SupportsFilter(Protocol):
|
||||
def filter(self, record: LogRecord, /) -> bool: ...
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from re import Pattern
|
||||
from socket import SocketKind, socket
|
||||
from threading import Thread
|
||||
from types import TracebackType
|
||||
from typing import Any, ClassVar, Final, Protocol, TypeVar
|
||||
from typing import Any, ClassVar, Final, Protocol, TypeVar, type_check_only
|
||||
from typing_extensions import Self
|
||||
|
||||
_T = TypeVar("_T")
|
||||
@@ -225,6 +225,7 @@ class HTTPHandler(Handler):
|
||||
def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ...
|
||||
def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented
|
||||
|
||||
@type_check_only
|
||||
class _QueueLike(Protocol[_T]):
|
||||
def get(self) -> _T: ...
|
||||
def put_nowait(self, item: _T, /) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user