mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-29 11:16:44 +08:00
Add @type_check_only to stub-only private classes in stdlib (#14512)
This commit is contained in:
+11
-2
@@ -1340,6 +1340,9 @@ class property:
|
||||
def __set__(self, instance: Any, value: Any, /) -> None: ...
|
||||
def __delete__(self, instance: Any, /) -> None: ...
|
||||
|
||||
# This class does not exist at runtime, but stubtest complains if it's marked as
|
||||
# @type_check_only because it has an alias that does exist at runtime. See mypy#19568.
|
||||
# @type_check_only
|
||||
@final
|
||||
class _NotImplementedType(Any):
|
||||
__call__: None
|
||||
@@ -1513,7 +1516,7 @@ help: _sitebuiltins._Helper
|
||||
def hex(number: int | SupportsIndex, /) -> str: ...
|
||||
def id(obj: object, /) -> int: ...
|
||||
def input(prompt: object = "", /) -> str: ...
|
||||
|
||||
@type_check_only
|
||||
class _GetItemIterable(Protocol[_T_co]):
|
||||
def __getitem__(self, i: int, /) -> _T_co: ...
|
||||
|
||||
@@ -1768,7 +1771,7 @@ def open(
|
||||
opener: _Opener | None = None,
|
||||
) -> IO[Any]: ...
|
||||
def ord(c: str | bytes | bytearray, /) -> int: ...
|
||||
|
||||
@type_check_only
|
||||
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T_contra]): ...
|
||||
|
||||
@overload
|
||||
@@ -1787,12 +1790,15 @@ def print(
|
||||
_E_contra = TypeVar("_E_contra", contravariant=True)
|
||||
_M_contra = TypeVar("_M_contra", contravariant=True)
|
||||
|
||||
@type_check_only
|
||||
class _SupportsPow2(Protocol[_E_contra, _T_co]):
|
||||
def __pow__(self, other: _E_contra, /) -> _T_co: ...
|
||||
|
||||
@type_check_only
|
||||
class _SupportsPow3NoneOnly(Protocol[_E_contra, _T_co]):
|
||||
def __pow__(self, other: _E_contra, modulo: None = None, /) -> _T_co: ...
|
||||
|
||||
@type_check_only
|
||||
class _SupportsPow3(Protocol[_E_contra, _M_contra, _T_co]):
|
||||
def __pow__(self, other: _E_contra, modulo: _M_contra, /) -> _T_co: ...
|
||||
|
||||
@@ -1857,9 +1863,11 @@ def repr(obj: object, /) -> str: ...
|
||||
# and https://github.com/python/typeshed/pull/9151
|
||||
# on why we don't use `SupportsRound` from `typing.pyi`
|
||||
|
||||
@type_check_only
|
||||
class _SupportsRound1(Protocol[_T_co]):
|
||||
def __round__(self) -> _T_co: ...
|
||||
|
||||
@type_check_only
|
||||
class _SupportsRound2(Protocol[_T_co]):
|
||||
def __round__(self, ndigits: int, /) -> _T_co: ...
|
||||
|
||||
@@ -1881,6 +1889,7 @@ def sorted(iterable: Iterable[_T], /, *, key: Callable[[_T], SupportsRichCompari
|
||||
_AddableT1 = TypeVar("_AddableT1", bound=SupportsAdd[Any, Any])
|
||||
_AddableT2 = TypeVar("_AddableT2", bound=SupportsAdd[Any, Any])
|
||||
|
||||
@type_check_only
|
||||
class _SupportsSumWithNoDefaultGiven(SupportsAdd[Any, Any], SupportsRAdd[int, Any], Protocol): ...
|
||||
|
||||
_SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWithNoDefaultGiven)
|
||||
|
||||
Reference in New Issue
Block a user