Add @type_check_only to stub-only private classes in stdlib (#14512)

This commit is contained in:
Brian Schubert
2025-08-03 04:13:16 -04:00
committed by GitHub
parent dde70aeecd
commit 622df68c1c
61 changed files with 188 additions and 51 deletions
+7 -1
View File
@@ -4,28 +4,34 @@ import socketserver
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterable, Mapping
from re import Pattern
from typing import Any, ClassVar, Protocol
from typing import Any, ClassVar, Protocol, type_check_only
from typing_extensions import TypeAlias
from xmlrpc.client import Fault, _Marshallable
# The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy
@type_check_only
class _DispatchArity0(Protocol):
def __call__(self) -> _Marshallable: ...
@type_check_only
class _DispatchArity1(Protocol):
def __call__(self, arg1: _Marshallable, /) -> _Marshallable: ...
@type_check_only
class _DispatchArity2(Protocol):
def __call__(self, arg1: _Marshallable, arg2: _Marshallable, /) -> _Marshallable: ...
@type_check_only
class _DispatchArity3(Protocol):
def __call__(self, arg1: _Marshallable, arg2: _Marshallable, arg3: _Marshallable, /) -> _Marshallable: ...
@type_check_only
class _DispatchArity4(Protocol):
def __call__(
self, arg1: _Marshallable, arg2: _Marshallable, arg3: _Marshallable, arg4: _Marshallable, /
) -> _Marshallable: ...
@type_check_only
class _DispatchArityN(Protocol):
def __call__(self, *args: _Marshallable) -> _Marshallable: ...